struct xuesheng{ int num; struct xuesheng *next;};typedef struct xuesheng DN;DN *input1109(){ DN *head,*p1,*p2; int i,n; printf("请输入需要输入的学生个数:"); scanf("%d",&n); head=NULL; for (i=0;i<n;i++) { if(i=0) { p1=(DN *)malloc(sizeof(DN)); head=p1; p1->num=i+1; p2=p1; } else { p1=(DN *)malloc(sizeof(DN)); p1->num=i+1; p2->next=p1; // p2=p1; } } p2->next=head; return(head);}void print1109(DN *head){ DN *p1,*p2; int k=1; p1=p2=head; while(p2!=p2->next) { do { if(k!=3) { p2=p1; p1=p1->next; p2=p2->next; k++; } else { p1=p1->next; p2->next=p1->next; k=0; } }while(k!=3); } printf("The last memeber is %d.",p2->num);}void Q1109(){ DN *head; head=input1109();// print1109(head);}
添加回答
举报
0/150
提交
取消