#include <stdio.h>
#define Long 4
typedef struct Link{
int a;
struct Link *next;
}link;
void ini(link *temp){
int i;
for ( i=1; i<=Long; i++) {
link *a=(link*)malloc(sizeof(link));
a->a=i;
a->next=NULL;
temp->next=a;
temp=temp->next;
}
}
// 1 2 3 4
// 2 3 4 1
// 3 4 2 1
// 4 3 2 1
void reversal(link *temp){
int i;
link *t = temp->next;
link *h = temp->next;
link *t1 = NULL;
while (t->next != NULL)
t = t->next;
temp->next = t;
for(i=1; i<Long; i++){
t->next = h;
h= h->next;
t->next->next = t1;
t1 = t->next;
}
}
void show(link *temp){
while (temp->next != NULL){
temp = temp->next;
printf("%d\n",temp->a);
}
}
int main (void){
link *head = (link*)malloc(sizeof(link));
link *temp=head;
ini(temp);
show(temp);
reversal(temp);
printf("====================\n");
show(temp);
return 0;
}