学习不可少
struct student {int num; int score; struct student *next;}; struct student *del(struct student *head,int num) {struct student *p1,*p2; if(head==NULL) {printf("\nlist null! \n"); } p1=head; while(num!=p1->num&&p1->next!=NULL) {p2=p1; p1=p1->next;} if(num==p1->num) {if(p1==head) head=p1->next; else p2->next=p1->next; printf("delete :%d\n",num); n=n-1;} else printf("%d not been found!\n",num); return(head);}
struct student *insert(struct student *head,struct student *stud) {struct student *p0,*p1,*p2;
p1=head; p0=stud; if(head==NULL) {head=p0;p0->next=NULL;} else {while((p0->num>p1->num)&&(p1->next!=NULL)) {p2=p1;p1=p1->next;} if(p0->num<=p1->num) {if(head==p1) head=p0; else p2->next=p0; p0->next=p1; } else { p1->next=p0; p0->next=NULL; } }
return(head); }