1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
V125BC [204]
3 years ago
5

Write a program that reads a string of characters, pushing each character onto a stack as it is read and simultaneously adding i

t to a queue. When the end of the string is encountered the program should use basic stack and queue operations to determine if the word is a palindrome.
Computers and Technology
1 answer:
sleet_krkn [62]3 years ago
4 0

Answer:

#include <iostream>

#include <stack>

#include <queue>

#include <string>

int main()

{

   while ( true )

   {

       std::string letters;

       std::cout << "Please enter a word (Enter - exit): ";

       std::getline( std::cin, letters );

       if ( letters.empty() ) break;

       std::stack<char>

           s( std::stack<char>::container_type( letters.begin(), letters.end() ) );

       std::queue<char>

           q( std::queue<char>::container_type( letters.begin(), letters.end() ) );

       while ( !s.empty() && s.top() == q.front() )

       {

           s.pop();

           q.pop();

       }

if ( s.empty() ) std::cout << "The word is a palindrome" << std::endl;

       else std::cout << "The word is not a palindrome" << std::endl;

   }

   return 0;

}

Explanation:

A <em>stack</em> is used to replicate a stack data structure in C++  while <em>Queue </em>container is a replica of the queue data structure in C++, Unlike stack, in the queue container, there are two ends, i.e. front, and back.

In the code above to be able to use used stack and queue, we included the headers #include <stack> and#include <queue>.

You might be interested in
A cell reference in a formula allows you to point to another cell location
mario62 [17]

The cell reference refers to a cell on a worksheet and can be used in a formula to point another location.

Explanation:

A cell reference is a range of cells on a worksheet that can be used in a formula to find the values or data you want to calculate using that formula.

There are two types of cell references relative and absolute. they both behave differently when copied to other cells. Relative references change when a formula is copied to another cell.

Absolute reference remains constant even if they are copied. In a formula multiplications are performed before subtraction.

It does not change when the formula is copied or moved to another cell.

6 0
3 years ago
Read 2 more answers
A print server uses a print ________ as a software holding area for jobs waiting to be printed.
vichka [17]

Answer:

spooler

Explanation:

A print server uses a print spooler as a software holding area for jobs waiting to be printed.

8 0
2 years ago
Read 2 more answers
An example of a(n) ____ reconnaissance attack is a user who sends SQL injections to a system in hopes of generating some type of
Elden [556K]
The answer to this question is A
7 0
3 years ago
Read 2 more answers
Draw a flowchart to input a number and find out whether it is divisible by 7 or not​
Over [174]

Note:

% is Modulus,

So it's taken as num mod 7, if that evaluates to 0 there is no reminder therefore divisible by 7.

7 0
2 years ago
In 5-10 sentences, describe the purposes, design considerations, and common elements of most brochures.
lozanna [386]
The primary thing to consider when designing a brochure is the target audience. <span> Brochures are meant to capture attention and deliver information, so it's important that the audience will want to read it in the first place.</span> When planning the design, consider the placement of elements and how they are arranged, or the 'white space'. Also take into consideration whether photos will be used. This ensures readability. <span>Also plan for the brochure's color scheme and fonts. These capture the audience so these are core parts of the design.</span>
4 0
3 years ago
Other questions:
  • The icons to insert pictures and clip art in the PowerPoint application are located in the _____ grouping on the Insert tab.
    7·1 answer
  • Complete the following:_____
    9·1 answer
  • To go to a specific cell, press the function key
    9·1 answer
  • What is the management part of a dashboard?
    10·1 answer
  • What is one invention that has had an impact on the way you live?<br><br>Write an essay
    15·2 answers
  • You install a teanviewer on your work station at home so that you can access it when on the road. How can you be assured that un
    12·1 answer
  • Write a copy constructor for carcounter that assigns origcarcounter.carcount to the constructed object's carcount. sample output
    15·2 answers
  • Write on the importance of Computer application to statistics​
    6·1 answer
  • Which option ensures that a page break is automatically inserted ahead of a specific paragraph or heading?
    10·2 answers
  • Write a program that prompts the user to enter a number then counts the number of odd numbers and even numbers the user enter. T
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!