Question: How do I show the number in case 3 ? For example, if I input 1992 , how to write a code to show that

How do I show the number in case 3?

For example, if I input 1992, how to write a code to show that how many 9 numbers in the element?

It's supposed to be 2, but my code shows 4.

I know I cannot use "Index", but what supposed to use?

How do I show the number in case 3? For example, if

My code below:

---------------------------------------------------------------

#include #include #include #include

using namespace std;

struct Node { Node *previous; Node *next; int number; };

int main() { Node *head = NULL; Node *tail = NULL; Node *n; int opt, index = 0, temp, number; char ans = 'y';

while (ans == 'y') { system("cls"); cout > opt;

switch (opt) {

case 1:

system("cls"); n = new Node;//command new create index++; cout > temp; n->previous = NULL; n->number = temp; n->next = head; head = n; if (index == 1) { tail = n; } if (index > 1) { n = n->next; n->previous = head; } break;

case 2:

system("cls"); n = new Node;//comand new create index++; if (index == 1) { head = NULL; } cout > temp; n->previous = tail; n->number = temp; n->next = NULL; tail = n; if (head == NULL) { head = n; n->previous = NULL; } else { n = n->previous; n->next = tail; } break;

case 3:

system("cls"); cout > temp; n = head; while (temp != NULL) { if (n->number == temp) { cout number next; if ((n->next == NULL) && (n->number != temp)) { cout

case 4:

// Traverse and Display List Elements if( index > 0 ) { cout next != NULL) { cout number next; } cout number

case 5:

// Traverse and Display List Elements in REVERSE order if( index > 0 ) { cout previous != NULL) { cout number previous; } cout number

case 6:

system("cls"); cout > temp; n = head; while (temp != NULL) { if (n->number == temp) { cout > n->number; break; } else { n = n->next; if ((n->next == NULL) && (n->number != temp)) { cout

case 7:

system("cls"); ans = false; break;

default:

system("cls"); cout

} } }

CA plCSCI15Labassignment8.exe ter the number you want to search: 9 lumber 9 Found, and total are 4 ralues Users 39411\ Deskto 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!