#include <stdio.h> #include <stdlib.h> #include <string.h> #define sg struct gammal struct gammal{ -char name[20]; -int payment; -struct gammal *next, *prev; }; sg* add (sg *g, sg *head){ -if(head==NULL || g->next == head){ --sg *t = (sg*)malloc(sizeof(sg)); --printf("Enter the name: "); --scanf("%s",t->name); --printf("Enter payment: "); --scanf("%d",&t->payment); --if(head == NULL){ ---t->next = t; ---t->prev = t; ---return t; --} --t->next = head; --head->prev = t; --g->next = t; --t->prev = g; --return g; -} -g->next = add(g->next,head); -return g; } void show (sg *g,sg *head){ -do{ --printf("------ "); --printf("%s ",g->name); --printf("%d ",g->payment); --g = g->prev; -}while(g != head); -printf("------ "); } int main() { -int a; -sg *head=NULL; -do{ --printf("1) Add " ----"2) Show " ----"Please, enter a number: "); --scanf("%d",&a); --if(a==1) ---head = add(head,head); --else if(a==2) ---show(head,head); -}while( a ); }