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
What type of software can you use to capture and examine the contents of network messages?
Ludmilka [50]
They're usually referred to as packet sniffers.
7 0
3 years ago
How does an Ac Machine work
Pani-rosa [81]

Answer:

In a split system, the compressor condenses and circulates the refrigerant through the outdoor unit, changing it from a gas to a liquid. The liquid is then forced through the indoor evaporator coil or cooling compartment. The indoor unit's fan circulates the inside air to pass across the evaporator fins.

Explanation:

(hope this helps)

6 0
2 years ago
vertical exchanges are typically used only to buy and sell materials required for an organization's support activities ( True or
torisob [31]

Answer:

Vertical exchanges are typically used only to buy and sell materials required for an organization's support activities- False

7 0
3 years ago
Read 2 more answers
I am a you tuber that does videos on the rob lox myth community, I have over 250+ subscribers. I was wondering if any of y'all w
Marina86 [1]

Answer:

I will for sure subscribe!!!!

Explanation:

:)

7 0
3 years ago
For each call of a function, the python virtual machine must allocate a small chunk of memory on the call stack, which is known
PtichkaEL [24]

For each call of a function, the python virtual machine must allocate a small chunk of memory on the call stack, which is known as <u>stack frame.</u>

<u></u>

<h3>What Does Stack Frame Mean?</h3>

A stack frame is a memory management technique used in some programming languages for generating and eliminating temporary variables. In other words, it can be considered the collection of all information on the stack pertaining to a subprogram call.

Stack frames are only existent during the runtime process. Stack frames help programming languages in supporting recursive functionality for subroutines.

A stack frame is comprised of:

  • Local variables
  • Saved copies of registers modified by subprograms that could need restoration
  • Argument parameters
  • Return address

Learn more about stack frame

brainly.com/question/9978861

#SPJ4

5 0
1 year ago
Other questions:
  • How to get administrator privileges on windows 7?
    13·1 answer
  • Serveral cheetas are growling at each other while hunting for animals.for which need are they competing?
    14·1 answer
  • I need help <br> Match each words with its definition!!!<br> Please helpppppppp
    12·1 answer
  • Arrange the steps below to outline what maia needs to do to accomplish this task.​
    9·1 answer
  • Linda subscribes to a cloud service. The service provider hosts the cloud infrastructure and delivers computing resources over t
    10·1 answer
  • Identify the benefit of modeling to communicate a solution.
    10·1 answer
  • Assume variables SimpleWriter out and int n are already declared in each case. Write a while loop that printsA. All squares less
    11·1 answer
  • Do yall think I should be lonely and quit life!!
    8·2 answers
  • What are the steps in preparing a bootable USB installer?​
    11·1 answer
  • Do you trust machine learning application?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!