#include#include struct Test { int data; struct Test *next; }; void printflink(struct Test *head) { struct Test *p=head; while(p != NULL){ printf("%d ",p->data); p=p->next; } putchar('n'); } struct Test *sf1(struct Test *new,struct Test *head)//第一种函数分装 { struct Test *p=head; if(p == NULL){ head=new; return head; } while(p->next != NULL){ p=p->next; } p->next=new; return head; } struct Test *dwc(struct Test *head)//第二种 { struct Test *p=head; int i=0; int j=0; struct Test *new=NULL; while(1){ new=(struct Test *)malloc(sizeof(struct Test)); printf("plese input your numbern"); scanf("%d",&(new->data)); if(new->data == 0){ free(new); return head; } head=sf1(new,head); } } int main() { struct Test *head=NULL; head=dwc(head); printflink(head); return 0; }



