#include<iostream>
#include<cstdio>
#include<string.h>
using namespace std;
int hws(int n) {
int a[1231];
int num = 0;
do{
a[num++] = n % 10;
n /= 10;
} while (n != 0);
int sum = 0;
for (int i =0; i < num; i++)
{
sum =sum*10+a[i];
}
return sum;
}
bool shw(int n) {
int a[1231];
int num = 0;
while (n != 0)
{
a[num++] = n % 10;
n /= 10;
}
for (int i =0; i<num/2; i++)
{
if (a[i] != a[num- i-1])
return false;
}
return true;
}
int main()
{
int n;
cin >> n;
int count = 0;
while (shw(n) == 0 && count < 10)
{
int a;
a = hws(n);
int b;
b = a + n;
cout << n << " " << "+" << " " << a << " " << "=" << " " << b << endl;
count++;
n = b;
}
if (count < 10)
{
cout << n << " is a palindromic number.";
}
else
{
cout << "Not found in 10 iterations.";
}
return 0;
}
不知道为什么有两个测试点过不了