You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.1 KiB

7 years ago
#include <iostream>
#include <cstring>
#include <climits>
7 years ago
#include "lychrel.hpp"
int main(int argc, char **argv)
{
string a = argv[1];
string b(a.rbegin(),a.rend());
string added = add(a,b);
if(added == "-1") {
cerr << "ERROR: adding error detected, we might have reached the end of our datatype or some how the two numbers don't have the same legth\n";
return 1;
}
7 years ago
long long it = 0;
do {
cout << "Iteration " << ++it << " currently working on " << added << endl;
a = added;
b = string(a.rbegin(),a.rend());
added = add(a,b);
if(added == "-1") {
cerr << "ERROR: adding error detected, we might have reached the end of our datatype or some how the two numbers don't have the same legth\n";
return 1;
}
} while(! is_palindrome(added));
7 years ago
cout << "Iteration " << ++it << " currently working on " << added << endl;
cout << "That consists of\n" << a << "\n+\n" << b << "\nand that it " << (is_palindrome(added) ? "is" : "is not") << " a palindrome." << endl;
7 years ago
return 0;
}