Note :::: Please, I need output too. And use C++ language. I post this question
ID: 3816258 • Letter: N
Question
Note :::: Please, I need output too. And use C++ language. I post this question before but the code is not working at all.
So please do it from beginning. Thanks in advance. Also both task please::
Task 1:
Implement a Queue on a char [] array. Do not use ::Queue:: class from the STD library for this example.
The user will input a string and the program will return the string with each letter in the string duplicated. Displaying correct Queue implementation.
Utilize the conventional static methods as needed.
empty()
push_back()
pop_front()
Sample Execution
Please input String:
happy
hhaappyy
Task 2:
Implement a Queue using a vector or the STD ::queue:: class
Note the difference in what it takes to implement using a static char[] array vs a vector or the STD ::queue:: class
The user will input a string and the program will return the string with each letter in the string duplicated. Displaying correct Queue implementation.
Utilize the conventional static methods as needed.
empty()
push_back()
pop_front()
Sample Execution
Please input String:
happy
hhaappyy
Explanation / Answer
// Credit goes to Gabehabe at Dream in Code
// http://www.dreamincode.net/forums/topic/57487-stl-queues/
//
// The story and names have been changed to protect the innocent.
#include <iostream>
#include <queue>
#include <string>
using namespace std;
int main ()
{
queue <string> names;
names.push ("Test1"); /* Add some values to the queue */
names.push ("Test2"); /* Much like vectors */
names.push ("Test3"); /* This basically does the same thing */
cout << "Welcome to India Coney and Cone!" << endl << endl;
cout << "Now serving: "
<< names.front () << endl << endl;
names.pop ();
cout << "There are currently " << names.size ()
<< " people in the queue. "
<< "The next person in the queue is "
<< names.front () << "." << endl << endl
<< names.back () << " is the last person in the queue."
<< endl;
cin.get ();
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.