#include<stdio.h>
#include<malloc.h>
struct stu
{int num;
struct stu *next;
} ;
struct stu *creat(void)
{int temp; struct stu *p1,*p2;
struct stu *head=NULL;
printf("/n input number:");
while(scanf("%d",&temp)&&temp!=0)
{p1=(struct stu *)malloc(sizeof(struct stu));
if(head==NULL)
head=p1;
else
p2->next=p1;
p1->num=temp;
printf("input number:");
p2=p1;
}
p2->next=NULL;
return (head);
}
void Free (struct stu *head)
{ struct stu *p,*q;
p=head;
while(p->next!=NULL)
{q=p->next;p->next=q->next;
free(q);
}free(head);}
void output(struct stu *head)
{
struct stu *p1,*p2;for(p1=head;p1!=NULL;printf("%d",p1->num),p1=p1->next);
}
struct stu * turnback(struct stu *head)
{struct stu *new,*newhead=NULL;struct stu *p1,*p2;
do{p2=NULL;
p1=head;
while(p1->next!=NULL){ p2=p1;p1=p1->next;}
if(newhead==NULL){newhead=p1;newhead->next=p2;new=newhead;}
new=new->next=p2;
p2->next=NULL;
}while(head->next!=NULL);
return(newhead);
}
void main()
{struct stu *head;
head=creat();
printf("The original list:/n");
output(head);
head=turnback(head);printf("/nThe new list:/n");
output(head);
printf("/n");
Free(head);
getch();