-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPALIN.cpp
More file actions
55 lines (48 loc) · 797 Bytes
/
Copy pathPALIN.cpp
File metadata and controls
55 lines (48 loc) · 797 Bytes
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
52
53
54
55
#include <iostream>
#include <string>
#include <vector>
using namespace std;
struct BI{
vector<short> num ;
BI(){
num = vector<short>();
char ch;
while((ch = cin.get())!='\n')
num.push_back(ch-'0');
}
void pp(int pos){
if(pos == -1)
num.insert(num.begin(),1);
else if(num[pos] == 9){
num[pos] = 0;
pp(pos-1);
}else
num[pos]++;
}
void pp(){
pp(num.size()-1);
}
operator bool(){
for(int i=0;i<=num.size()/2;i++)
if(num[i]!=num[num.size()-i-1])
return false;
return true;
}
string to_string(){
string str = "";
for(int i=0;i<num.size();i++)
str+=::to_string(num[i]);
return str;
}
};
int main(){
int T;
cin >> T;
cin.get();
while(T--){
BI n = BI();
do{n.pp();}while((bool)n);
cout << n.to_string() << endl;
}
return 0;
}