|
|
@ -1,5 +1,6 @@
|
|
|
|
#include <iostream>
|
|
|
|
#include <iostream>
|
|
|
|
#include <cstring>
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
#include <climits>
|
|
|
|
#include "lychrel.hpp"
|
|
|
|
#include "lychrel.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -8,16 +9,23 @@ int main(int argc, char **argv)
|
|
|
|
string a = argv[1];
|
|
|
|
string a = argv[1];
|
|
|
|
string b(a.rbegin(),a.rend());
|
|
|
|
string b(a.rbegin(),a.rend());
|
|
|
|
string added = add(a,b);
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
long long it = 0;
|
|
|
|
long long it = 0;
|
|
|
|
do {
|
|
|
|
do {
|
|
|
|
cout << "Iteration " << ++it << " currently working on " << added << endl;
|
|
|
|
cout << "Iteration " << ++it << " currently working on " << added << endl;
|
|
|
|
a = added;
|
|
|
|
a = added;
|
|
|
|
b = string(a.rbegin(),a.rend());
|
|
|
|
b = string(a.rbegin(),a.rend());
|
|
|
|
added = add(a,b);
|
|
|
|
added = add(a,b);
|
|
|
|
} while(! is_palindrome(added) );
|
|
|
|
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));
|
|
|
|
cout << "Iteration " << ++it << " currently working on " << added << endl;
|
|
|
|
cout << "Iteration " << ++it << " currently working on " << added << endl;
|
|
|
|
cout << "That consists of\n" << a << "\n+\n" << b << "\nand that it is a palindrome." << endl;
|
|
|
|
cout << "That consists of\n" << a << "\n+\n" << b << "\nand that it " << (is_palindrome(added) ? "is" : "is not") << " a palindrome." << endl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|