//node Structure Bodystructinv{intI//node Element structinv*Nextpointer;};//returns a pointer to the specified element node, and returns NULL when not includedstructInv* contain (intIstructinv*head) { structINV *headp=Head; while(headp!=NULL) { if(headp->i==i) { Break; } HEADP=headp->Nextpointer; } returnheadp;}//Append ElementintAppendintIstructINV * *HEADPP) { structINV *headp=*HEADPP; structINV *prev; if(*headpp==NULL) { *headpp= (structinv*)malloc(sizeof(structinv)); (*HEADPP)->i=i; (*HEADPP)->nextpointer=NULL; return 1; } while(headp!=NULL) {prev=HEADP; if(headp->i==i) {return 0; } HEADP=headp->Nextpointer; } prev->nextpointer= (structinv*)malloc(sizeof(structinv)); Prev=prev->Nextpointer; Prev->i=i; Prev->nextpointer=NULL; return 1;}//Delete the specified elementintDeleintIstructINV * *HEADPP) { intReturnvalue=0; structinv*prev; structinv*headp=*HEADPP; if(headp==NULL) { return 0; } while(headp->i!=i&&headp->nextpointer!=NULL) {prev=HEADP; HEADP=headp->Nextpointer; } if(headp->i==i) {if(headp==*HEADPP) { *headp=*headp->Nextpointer; } prev->nextpointer=headp->Nextpointer; Free(HEADP); return 1; } return 0;}//Delete entire linked listvoidDeleteAllstructinv**head) { structinv*headp=*Head; structinv*temp; while(headp!=NULL) {Temp=headp->Nextpointer; Free(HEADP); HEADP=temp; } *head=NULL;}//Scan PrintvoidPaintstructinv*headp) { while(headp!=NULL) {printf ("%d\n",headp->i); HEADP=headp->Nextpointer; }}
CPP source file: Http://pan.baidu.com/s/1bodkQRX
Linked List.cpp file
The realization of data structure---non-repeating element chain list