/
wsq11.cpp
51 lines (50 loc) · 1.27 KB
/
wsq11.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# TC1017
//CarolinaRomo...WSQ11
#include <iostream>
#include <cstring>
#include <algorithm>
#include "BigIntegerLibrary.hh"
using namespace std;
bool checking (BigInteger num){
string str1 = bigIntegerToString(num);
reverse (srt1.begin(), str1.end());
BigInteger num2 = stringToBigInteger(str1);
return (num == num2);
}
BigInteger Inverter(BigInteger num){
for(int i=0; i<=30 && checking(num) == false; n++){
string str2 = bigIntegerToString(num);
reverse (str2.begin(), str2.end());
BigInteger num3 = stringToBigInteger(str2);
num = num+num3;
}
return c;
}
int main (){
int palindromes=0, lycherel=0, changer=0;
int lowb,upb;
BigInteger num;
cout << "Please give me the lower bound: " << endl;
cin >> lowb;
cout << "Please give me the upper bound: " << endl;
cin >> upb;
for (BigInteger num=lowb; num<=upb; num=num+){
if(checking(num) == true){
palindromes++;
}
else {
num = Inverter(num);
if(checking(num) == true){
changer++;
}
else{
cout << "I found a Lycherel number: " << num << " is Lychrel." << endl;
lycherel++;
}
}
}
cout << "Natural Palindromes: " << palindromes << endl;
cout << "Non-Lycherel Palindromes " << changer << endl;
cout << "Lycherels" << lycherel << endl;
return 0;
}