1、#include #include usingnamespacestd;classNodepublic:intdata;Node *next;public:Node()next=NULL;Node(inta)data=a;next=NULL;classListpublic:Node *head;public:List()head=newNode();List()Node *p=head-next;while(p) Node *s=p;p=s-next;free(s);free(head);voidinitial()Node *zhen;zhen=head;inti;cini;for(intj=
2、0;js-data;zhen-next=s;zhen=s;s-next=NULL;intgetList_Length()Node *ss;inti=0;ss=head-next;while(ss)i+;ss=ss-next;returni;intsearch(inta)Node *find;find=head-next;if(athis-getList_Length()|anext;returnfind-data;intInsert_List(inta,intb)Node *Insert;Insert=head-next;if(a=1)Node *ss=newNode(b);head-next
3、=ss;ss-next=Insert;return1;if(athis-getList_Length()+1|a1)Insert=head-next;for(inti=0;inext;Node *ss=newNode(b);ss-next=Insert-next;Insert-next=ss;return1;intDelete_List(inta)Node *find;inti;find=head-next;if(a=1)Node *ss;ss=head-next;head-next=ss-next;free(ss);return1;if(athis-getList_Length()return0;elseif(a1)for(i=0;inext; Node *ss;ss=find-next;ss-next=find-next;free(ss);return1;voidDisplay()Node *ss;ss=head-next;while(ss!=NULL)coutdatanext;coutac;if(list.Insert_List(a,c)=0)couta;if(list.Delete_List(a)=0)couta;if(list.search(a)=0)cout“error“endl;elsecoutlist.search(a)endl;return0;