There is such a condition:
Develop a program for the task - to form a unidirectional list of the input string. In the field of each element of the list, write a separate symbol. If the first character is the letter “A”, then add one more letter “A” to the end of the list, otherwise, delete all the letters “A” from the list. Print the result.
I coped with the first condition and added another letter to the end of the list, but I can’t with the second one. My code is:
Node *pv = new Node; char b; pv = head; if (pv->item != 'A') { while (pv->next != NULL) { if (pv->item == 'A') { delete pv; } pv = pv->next; } } I understand that you can not do it right away: delete pv. But I just do not know how to solve this problem. I would be very grateful for the help.