#include #include "a:list.h" int menu(void); void pause(void); main() { List list; ItemType item; int i, n, choice; CreateList(&list); do { choice = menu(); switch(choice) { //creates a list case 1 : clrscr(); printf("Enter the number of nodes you wish to add in the list: "); scanf("%d" , &n); for(i=1 ; i <= n ; i++) { clrscr(); printf("Enter next item: "); scanf("%d", &item.key); if (!FullList()) Insert(item, &list); } pause(); break; //inserts a node into the list case 2 : clrscr(); printf("Enter item for the node: " ); scanf("%d", &item.key); if (!FullList()) Insert(item, &list); pause(); break; //prints the nodes in the list case 3 : clrscr(); Traverse(&list); pause(); break; //seach for a node and display an appropriate message case 4 : clrscr(); printf("you need to implement this yourself"); pause(); break; //deletes a node if it exists case 5 : clrscr(); printf("you need to implement this yourself"); pause(); break; //exit case 6 : ClearList(&list); } } while (choice != 6); return 0; } int menu(void) { int choice, stat; do { clrscr(); printf("\n\n\n\t\t1. Create a list\n"); printf("\t\t2. Insert new node into list\n"); printf("\t\t3. Display the list\n"); printf("\t\t4. Search for an item in the list\n"); printf("\t\t5. Delete an item from list\n"); printf("\t\t6. Exit\n\n"); printf("\t\tPlease, enter your choice: "); stat=scanf("%d", &choice); } while(stat==0 || choice < 1 || choice > 6); return choice; } void pause(void) { printf("\nPress any key to continue..."); getch() ; }