#include<stdio.h>#include<stdlib.h>struct node {
int data;
struct node *next;
};
struct node *head = NulL;
struct node *current = NulL;
//insert link at the first locationvoID insert(int data){
// Allocate memory for new node;struct node *link = (struct node*) malloc(sizeof(struct node));
link->data = data;
link->next = NulL;
// If head is empty, create new Listif(head==NulL) {
head = link;
head->next = link;
return;
}
current = head;
// move to the end of the Listwhile(current->next != head)
current = current->next;
// Insert link at the end of the List
current->next = link;
// link the last node back to head
link->next = head;
}
//display the ListvoID reverse_print(struct node *List){
if(List->next == head) {
printf(" %d =>",List->data);
return;
}
reverse_print(List->next);
printf(" %d =>",List->data);
}
intmain(){
insert(10);
insert(20);
insert(30);
insert(1);
insert(40);
insert(56);
reverse_print(head);
printf(" [head]\n");
return0;
}