{"rsdb":{"rid":"156010","subhead":"","postdate":"0","aid":"117116","fid":"45","uid":"1","topic":"1","content":"
\n
\r\n#include \n  \n   \r\n#include \n   \n     #include \n    \n      typedef struct stData{ int e; }Data; typedef struct stLink{ Data data; struct stLink* next; }Link; struct Link* create(){ Link* head = (Link*)malloc(sizeof(Link)); memset(&head->data,0,sizeof(Link)); head->next = NULL; return head; } void head_insert(Link* head,Data e){ Link *pTemp,*pNew; if (head->data.e != 0){ pTemp = head->next; pNew = (Link*)malloc(sizeof(Link)); memcpy(&pNew->data,&e,sizeof(Data)); pNew->next = pTemp; head->next = pNew; }else{ memcpy(&head->data,&e,sizeof(Data)); } } void nial_insert(Link* head,Data e){ Link *pTemp,*pNew; pTemp = head; if (head->data.e != 0){ pNew = (Link*)malloc(sizeof(Link)); memcpy(&pNew->data,&e,sizeof(Data)); while(pTemp->next != NULL) pTemp = pTemp->next; pTemp->next = pNew; pNew->next = NULL; } else{ memcpy(&head->data,&e,sizeof(Data)); } } void dele(Link* head,Data e){ Link *pBefore = head; Link *pTemp = head; while(pTemp->next != NULL){ if (pTemp->data.e == e.e) { Link *pDel = pTemp; pBefore->next = pTemp->next; pDel->next = NULL; free(pDel); return; }else{ pBefore = pTemp; pTemp = pTemp->next; } } if (pTemp->data.e == e.e) { Link *pDel = pTemp; pBefore->next = pTemp->next; pDel->next = NULL; free(pDel); } } void show(Link* head){ Link *pTemp = head; while(pTemp->next != NULL){ printf(\"%d \\n\",pTemp->data.e); pTemp = pTemp->next; } printf(\"%d \\n\",pTemp->data.e); } int main() { Link *head = create(); Data e1={1001},e2={1002},e3={1003},e4={1004}; \/\/head_insert(head,e1); \/\/head_insert(head,e2); \/\/head_insert(head,e3); \/\/head_insert(head,e4); nial_insert(head,e1); nial_insert(head,e2); nial_insert(head,e3); nial_insert(head,e4); show(head); printf(\"dele------------\\n\"); dele(head,e2); show(head); return 0; } \n    <\/string.h>\n   <\/stdlib.h>\n  <\/stdio.h><\/pre> \n<\/dd>","orderid":"0","title":"c\u8bed\u8a00\u94fe\u8868\uff0c\u5934\u63d2\u6cd5\u548c\u5c3e\u63d2\u6cd5","smalltitle":"","mid":"0","fname":"c\u8bed\u8a00\u7f16\u7a0b","special_id":"0","bak_id":"0","info":"0","hits":"75","pages":"1","comments":"0","posttime":"2017-01-06 08:14:53","list":"1483661693","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"http:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"\u8bed\u8a00<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"14.17.22.31","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"c\u8bed\u8a00\u94fe\u8868\uff0c\u5934\u63d2\u6cd5\u548c\u5c3e\u63d2\u6cd5","lastview":"1487805979","digg_num":"0","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}