#include #define NODES 4 typedef struct list_head { struct node* head; struct node* tail; } list_head; typedef struct node { struct node* next; int value; } node; node n[NODES]; list_head init_empty_list() { list_head h; h.head = 0; h.tail = 0; return h; } list_head init_list() { int i; list_head h; for (i=0; ivalue); p = p->next; } printf("\n"); } list_head reverse_list(list_head h) { list_head nh; if ((h.head == 0) || (h.head->next ==0)) { return h; } nh.head = h.head->next; nh.tail = h.tail; nh = reverse_list(nh); h.head->next = 0; nh.tail->next = h.head; nh.tail = h.head; return nh; } int main() { list_head head; head = init_list(); print_list(head); head = reverse_list(head); print_list(head); return 0; }