int main() { node_t head; node_t *ph = &head; int nd = 3; head.v = 5; create_sll(&ph); print_sll(&ph); ph = reverse_sll(&ph); print_sll(&ph); del_sll(&ph, nd); print_sll(&ph); ph = reverse_sll(&ph); print_sll(&ph); return 0; }
int menu_body(char ch,int choice) { static int flag; int data,result; switch (ch) { case ESC: { clrscr(); flag=1; } break; case ENTER: { switch(choice) { case 0: { clrscr(); gotoxy(0,0); /*Please Add your function here*/ puts("Enter the new element to list"); fflush(stdout); scanf("%d",&data); result=insert_node_sll(&start,data); (result==1)?puts("Element has been added"):puts("Faild to enter the element"); puts("Enter any key to back to menu"); getch(); } break; case 1: { clrscr(); gotoxy(0,0); /*Please Add your function here*/ print_sll (start); puts("Enter any key to back to menu"); getch(); } break; case 2: { clrscr(); gotoxy(0,0); /*Please Add your function here*/ puts("Enter an element to find it"); fflush(stdout); scanf("%d",&data); result=find_sll (start ,data); (result==1)?printf("Element %d has been found\n",data) :printf("Element %d is not presented in list\n",data); puts("Enter any key to back to menu"); getch(); break; } break; case 3: clrscr(); gotoxy(0,0); /*Please Add your function here*/ puts("Enter an element to delete"); fflush(stdout); scanf("%d",&data); result=delete_sll(&start,data); (result==1)?puts("Element has been deleted"):puts("Element has not been found"); puts("Enter any key to back to menu"); getch(); break; case 4: clrscr(); gotoxy(0,0); /*Please Add your function here*/ result=get_count_sll(start); printf("Number of elements in list is %d\n",result); puts("Enter any key to back to menu"); getch(); break; case 5: clrscr(); gotoxy(0,0); /*Please Add your function here*/ free_list(&start); getch(); break; case 6: clrscr(); gotoxy(0,0); /*Please Add your function here*/ reverse_sll(&start); print_sll (start); getch(); break; case 7: flag=1; break; } } } return(flag); }