Ask your own question, for FREE!
Computer Science 8 Online
OpenStudy (anonymous):

1. Write a program that creates a queue of Strings and allows the input of an integer value n, followed by n names to be placed in the queue. Then the program should execute a loop that performs the following:  It displays the name in the front of the queue and asks the user to specify a number of names to be deleted. The user specifies a value and it deletes that number of names.  Each name deleted is displayed on the screen.  The two steps are continued until the queue is empty. In C++ This questions seems tough to me. I have no idea how to do it.

OpenStudy (anonymous):

#include<iostream> #include<queue> using namespace std; int main() { queue<string>myqueue; int i; char name[20]; cout<<"Enter integer value n:"; cin>>n; for(i=0; i<20; i++) printf("%d names placed in the queue", n); scanf("%d, &name[i]); \\ i dont know if its good. Correct me pls. @TuringTest

OpenStudy (turingtest):

it looks like you're not deleting the names, but this is actually just beyond what I'm comfortable with in C++. I'm still a student after all, and this is what I'm studying right now. Sorry I can't give you more help on this one.

OpenStudy (anonymous):

its ok TuringTest, i will try to figure it out. Thanks anyway. :)

OpenStudy (anonymous):

#include<iostream> #include<queue> using namespace std; int main() { int n; cout<<"Enter an integer value n:"; cin>>n; queue<string>names(n); cout<<"%d names placed in the queue", n); for(int i=0, i<names.size(); i++) cout<<"Name in the front of the queue"<<names.front()<<""<<endl; cout<<"Specify a number of names to be deleted:"; int value; cin>>value; Cout<<"Removing %d names in the queue"<<value<<endl; while(names.size() !=0) { cout<<"Deleting names"<<names.front()<<endl; names.pop(); } if(names.empty()) cout<<"The queue is now empty!"; return 0; } \\I am not sure about the number of value the names should be deleted, i have put while(names.size() !=0) If somebody can correct me , .....

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!