Name: ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
- [100pts]
Download hw.cpp. It is supposed to work as follows.
-
It reads in ints from the user until a negative number is
entered, storing them into a linked list.
-
It will print out the contents of the list.
-
Enter a loop that ends on "quit" but takes a couple commands:
- "enter 7 after 9": You should insert the number (7) after the first occurrence of their target number (9).
- "remove 12": You should remove the number (12) from the list.
The program should print the current list from the front to the back, right
after executing a command.
Example runs:
$ ./hw
71 22 84 12 95 10 8 54 -1
71 22 84 12 95 10 8 54
> enter 23 after 12
71 22 84 12 23 95 10 8 54
> remove 84
71 22 12 23 95 10 8 54
> enter 40 after 22
71 22 40 12 23 95 10 8 54
> remove 71
22 40 12 23 95 10 8 54
> enter 77 after 95
22 40 12 23 95 77 10 8 54
> quit
Your Task
- Proivde library
ll so that the program works correctly.
- Use the following Makefile.
- Do not touch hw.cpp.
Tips
- Your program should end with no memory errors, when your
program is run with valgrind.
- For the "remove" command, a recursive solution will probably be easier.
Turn in