Write a program that uses a stack object to determine if a string is a palindrome (i.e., the string is spelled identically backward and forward). The program should ignore spaces and punc- tuation.
What will be an ideal response?
```
#include
#include
using namespace std;
#include "Stack.h"
int main()
{
Stack< char > charStack;
char c;
char string1[ 80 ];
char string2[ 80 ];
int i = 0;
cout << "Enter a sentence:\n";
// get input
while ( ( c = static_cast< char >( cin.get() ) ) != '\n' )
{
if ( isalpha( c ) )
{
string1[ i++ ] = c;
charStack.push( c );
} // end if
} // end while
string1[ i ] = '\0';
i = 0;
// get stack elements
while ( !charStack.isStackEmpty() )
charStack.pop( string2[ i++ ] );
string2[ i ] = '\0';
if ( strcmp( string1, string2 ) == 0 )
cout << "\nThe sentence is a palindrome\n";
else
cout << "\nThe sentence is not a palindrome\n";
return 0; // indicates successful termination
} // end main
```
Enter a sentence:
oat y tao
The sentence is a palindrome
All nodes destroyed
You might also like to view...
(TicTacToe Class) Create a class TicTacToe that will enable you to write a complete program to play the game of tic-tac-toe. The class contains as private data a 3-by-3 two-dimensional array of integers. The constructor should initialize the empty board to all zeros. Allow two human players. Wherever the first player moves, place a X in the specified square. Place an O wherever the second player
moves. Each move must be to an empty square. After each move, determine whether the game has been won or is a draw. If you feel ambitious, modify your program so that the computer makes the moves for one of the players. Also, allow the player to specify whether he or she wants to go first or second. If you feel exceptionally ambitious, develop a program that will play three-dimen- sional tic-tac-toe on a 4-by-4-by-4 board. [Caution: This is an extremely challenging project that could take many weeks of effort!] What will be an ideal response?
The typical relationship between tables is the one-to-many relationship
Indicate whether the statement is true or false
The ____ of a hashed list is the number of elements in the list divided by the number of physical elements allocated for the list, expressed as a percentage.
A. balance factor B. clustering factor C. load factor D. hashing factor
A format used for distributing web feeds that change frequently.
What will be an ideal response?