// FindPalindrome.cpp // This program tests an input string to see if it // is a palindrome (same backwards as forwards). // This program uses the STL as a demonstration // CS210 - S'03 - 3/18/03 - Ray S. Babcock // #include #include #include using namespace std; int main(void) { string line,reversedline; cout << "Enter your test phrase: "; getline(cin, line); reversedline = line; reverse(reversedline.begin(), reversedline.end()); string::iterator pos,rev; pos = line.begin(); rev = reversedline.begin(); while(pos != line.end()) { if(*pos != *rev) { cout << "Not a palindrome!" << endl; exit(-1); } pos++; rev++; } cout << "A palindrome!" << endl; }