68 369
Assignments Done
98,7%
Successfully Done
In November 2018

Answer to Question #55392 in C++ for paul

Question #55392
Write a program that reads a line of text, changes each uppercase letter to lowercase, and places each letter both in a queue and onto a stack. The program should then verify whether the line of text is a palindrome (a set of letters or numbers that is the same whether read forward or backward).
Expert's answer
#include <iostream>
#include <stdio.h>
#include <stack>
#include <queue>
using namespace std;

int main() {
stack<char> s;
queue<char> q;
int c;
while((c=getchar())!='\n') {
c=toupper(c);
s.push(c);
q.push(c);
}
char head;
char tail;
while(!s.empty()) {
head=q.front();
tail=s.top();
if(head!=tail) {
cout<<"Not palindrome\n";
return 0;
}
q.pop();
s.pop();
}
cout<<"Palindrome!\n";
return 0;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
16.10.15, 17:42

Dear aul, please use panel for submitting new questions

aul
15.10.15, 16:35

Identify and fully explain two types of intruder detection techniques (10)
2.2 With the aid of a fully labeled diagram, explain the use of Public-Key Encryption between two communication devices/users. (15)
2.3 Remote access protocols manage the connection between a remote computer and a remote access server. List and explain any four protocols used to connect a remote computer and a remote access server

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions