struct student* del(struct student* head, long num){struct student *p1, *p2;if(head == NULL){printf("\nlist null\n");goto end;}p1 = head;while(num != p1->num && p1->next != NULL)//p1指向的不是所要的結點,并且后還有結點。{p2 = p1;p1 = p1->next;//p1向后移一個結點。}if(num == p1->num){if(p1 == head){head = p1->next;}else{p2->next = p1->next;}printf("delete:%ld\n",num);n = n-1;}else{printf("%ld not been found!\n", num);//找不到該結點。}end://這個end是什么意思?為什么寫在這里?return head;}
添加回答
舉報
0/150
提交
取消