puts("\nWelcome to the menu for creation of linked lists.");
puts("\nWelcome to the menu for creation of linked lists.");
puts("Displaying possible actions:");
puts("Displaying possible actions:");
puts("1. Add at End;\n2. Delete Node;\n3. Insert Node;\n4. Search for value;\n5. Print a node;\n6. Print full list;\n7. Delete list and exit;");
puts("1. Add at End;\n2. Delete Node;\n3. Insert Node;\n4. Search for value;\n5. Print a node;\n6. Print full list;\n7. Delete list and exit;\n8. Print node prior to selected.\n");
fputs("Please input the number of your desired action: ",stdout);
fputs("Please input the number of your desired action: ",stdout);
scanf("%d",&choice);
scanf("%d",&input);
switch(choice)
switch(input)
{
{
case1://append
case1://append
fputs("You have decided to insert a value at the end. Input the desired value now: ",stdout);
fputs("You have decided to insert a value at the end. Input the desired value now: ",stdout);
scanf("%d",&value);
scanf("%d",&value);
add_to_end(head,value);
add_to_end(head,value);
break;
break;
case2://delete node
case2://delete node at
panic();
fputs("You have decided to delete a node. Input it: ",stdout);
scanf("%d",&index);
delete_node_at(head,index);
break;
break;
case3://insert
case3://insert
fputs("You have decided to insert a value at a specific point. Input the node index now: ",stdout);
fputs("You have decided to insert a value at a specific point. Input the node index now: ",stdout);
...
@@ -32,13 +34,13 @@ int menu(struct Node *head){
...
@@ -32,13 +34,13 @@ int menu(struct Node *head){
break;
break;
case4://search
case4://search
fputs("You have selected to search for a value. Please input the value now: ",stdout);
fputs("You have selected to search for a value. Please input the value now: ",stdout);
scanf("%d",&input);
scanf("%d",&value);
psearch(head,input);
psearch(head,value);
break;
break;
case5://print node
case5://print node
fputs("You have selected to print a node. Please input the node index now: ",stdout);
fputs("You have selected to print a node. Please input the node index now: ",stdout);
scanf("%d",&input);
scanf("%d",&index);
print_node_at(head,input);
print_node_at(head,index);
break;
break;
case6://print list
case6://print list
puts("Printing full list.");
puts("Printing full list.");
...
@@ -48,6 +50,14 @@ int menu(struct Node *head){
...
@@ -48,6 +50,14 @@ int menu(struct Node *head){
puts("Deleting the list...");
puts("Deleting the list...");
delete_list(head);
delete_list(head);
return1;
return1;
case8://return data two areas before
puts("Returning data at offset");
fputs("Please input the node index now: ",stdout);
scanf("%d",&index);
fputs("Please input the offset prior now: ",stdout);