puts("\nWelcome to the menu for creation of linked lists.");
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;\n8. Print node prior to selected.\n");
puts("0. Add at end;\n1. Insert node;\n2. Delete node by value;\n3. Delete node at index;\n4. Search for value;\n5. Print a node;\n6. Print full list;\n7. Print node prior to selected;\n8. Delete list and exit.\n");
fputs("Please input the number of your desired action: ",stdout);
scanf("%d",&input);
switch(input)
{
case1://append
case0://append
fputs("You have decided to insert a value at the end. Input the desired value now: ",stdout);
scanf("%d",&value);
add_to_end(head,value);
break;
case2://delete node at
fputs("You have decided to delete a node. Input it: ",stdout);
scanf("%d",&index);
delete_node_at(head,index);
break;
case3://insert
case1://insert
fputs("You have decided to insert a value at a specific point. Input the node index now: ",stdout);
scanf("%d",&index);
fputs("Please input the value now: ",stdout);
scanf("%d",&value);
insert_node(head,index,value);
break;
case2://delete node by value
fputs("You have decided to delete a node. Input it: ",stdout);
scanf("%d",&value);
if(delete_node(head,value)!=2){
delete_list(head);
return1;
}
break;
case3://delete node at index
fputs("You have decided to delete a node. Input the index: ",stdout);
scanf("%d",&index);
if(delete_node_at(head,index)!=2){
delete_list(head);
return1;
}
break;
case4://search
fputs("You have selected to search for a value. Please input the value now: ",stdout);
scanf("%d",&value);
...
...
@@ -46,18 +57,18 @@ int menu(struct Node *head){
puts("Printing full list.");
print_list(head);
break;
case7://delete list
puts("Deleting the list...");
delete_list(head);
return1;
case8://return data two areas before
case7://return data one 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);