#include <stdio.h> #include <stdlib.h> #include <string.h> #define sg struct gammal struct gammal{ -char name[20]; -int payment; -struct gammal *next; }; sg* add (sg *g,sg *head){ -if(g==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; ---return t; --} --else{ ---t->next = head; ---g->next = t; --} --return g; -} -g->next = add(g->next,head); -return g; } void show (sg *g){ -sg *head = g; -do{ --printf("------ "); --printf("%s ",g->name); --printf("%d ",g->payment); --g = g->next; -}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); -}while( a ); }