954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

need some guidance

I was viewing the practice problem section and decided to give a go at them, anyways, this is my Palindrome dector code. Could someone just take a look at it and explain to me if there is a better way to execute this problem?

- michael

// Palindrome check by Michael Turbe (c) 2009

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main(void)
{
// system config
system("TITLE Palindrome");

// variables
string User_Input;
string Input_Reverse;

string::iterator Position;

bool StartOver;

// loop allows multiple takes on program without restart
do
{
StartOver = false;
system("CLS");

cout << "Palindrome Check" << endl;
cout << "----------------" << endl << endl;
cout << "Enter a word or series of numbers." << endl << endl;

cin >> User_Input;

string Input_Reverse(User_Input.begin(), User_Input.end());

reverse(Input_Reverse.begin(), Input_Reverse.end());

if(User_Input == Input_Reverse)
{
cout << endl << User_Input << " is a Palindrome." << endl << endl;
}
else
{
cout << endl << User_Input << " and " << Input_Reverse << " are not the same." << endl << endl;
}

cout << "Would you like to start over? 1 - Yes, 0 - No" << endl;
cout << "Enter choice and press ENTER." << endl;
cin >> StartOver;
}

while(StartOver == true);

}

xtremerocker
Newbie Poster
14 posts since Jan 2009
Reputation Points: 37
Solved Threads: 0
 

Your answer seems fine to me.

There are many different ways of solving the problem, but whether any of them are "better" would be a subjective statement IMO.

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

True.

Thank you.

xtremerocker
Newbie Poster
14 posts since Jan 2009
Reputation Points: 37
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You