#include<stdlib.h>
typedef struct node
{
int data;
struct node*next;
}linklist;
linklist *creat()
{
linklist*head,*p,*t;
int i,n;
printf("input n:");
scanf("%d",&n);
head=(linklist*)malloc(sizeof(linklist));
t=head;
for(i=0;i<n;i++)
{
p=(linklist*)malloc(sizeof(linklist));
scanf("%d",&p->data);
t->next=p;
t=p;
}
p->next=NULL;
return head;
}
void convert(linklist*head)
{
linklist*p,*t;
p=head->next;
head->next=NULL;//把每壹個節點連接到頭結點後面即可,後面的節點與在連接
while(p)
{
t=p;
p=p->next;
t->next=head->next;
head->next=t;
}
}
void output(linklist*head)
{
linklist*p=head->next;
while(p)
{
printf("%d ",p->data);
p=p->next;
}
printf("\n");
}
void main()
{
linklist*p;
p=creat();
convert(p);
output(p);
}