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]
2 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]2 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
Kieran wants to search a database quickly for information on the last time a patient came to his medical facility. This informat
SpyIntel [72]
B I think is what it is
7 0
2 years ago
Read 2 more answers
What methods do phishing and spoofing scammers use?
Misha Larkins [42]

Answer:

please give me brainlist and follow

Explanation:

There are various phishing techniques used by attackers:

Installing a Trojan via a malicious email attachment or ad which will allow the intruder to exploit loopholes and obtain sensitive information. Spoofing the sender address in an email to appear as a reputable source and request sensitive information

4 0
2 years ago
You’re using Disk Manager to view primary and extended partitions on a suspect’s drive. The program reports the extended partiti
Sever21 [200]

Answer:

<em>b. There’s a hidden partition. </em>

Explanation:

The hidden partition <em>is a separate section set aside on OEM computer hard drives, often alluded to as the recovery partition and restore partition.</em>

This portion of memory is used by the manufacturer to preserve the data used to restore your computer to its default settings.

This function is particularly useful as it does not involve the CD or DVD of the operating system.

6 0
3 years ago
What are the missing parts to produce the following output?
hram777 [196]

Answer:

1.for

2.2

Explanation:

3 0
2 years ago
Good english songs to put in a power point
zheka24 [161]
Depends on what the powerpoint is about...
7 0
2 years ago
Other questions:
  • What command displays a computer s network settings?
    5·1 answer
  • What are some (free) good animation websites (for PC/Microsoft) for a short informational video about homelessness?
    15·1 answer
  • In Microsoft Word you can access the _______ command from the "Mini toolbar". A. insert citation B. save as C. underline D. word
    11·2 answers
  • Explain how SEO impacts the way you should interpret search engine results ???
    6·1 answer
  • A surface
    6·1 answer
  • Match the following.
    8·1 answer
  • GIVING OUT BRAINLIEST AND I AM ALSO WARNING EVERYONE TO NOT ANSWER A BUNCH OF rubbish just to get the points!
    7·2 answers
  • If you do a Find and Replace for a term, where will Word begin looking for the term?
    6·1 answer
  • List and briefly define the four main elements of a computer.​
    9·1 answer
  • Current flow is the same through all the elements of a series circuit.<br><br> true or false?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!