思路:水题
代码如下:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;
int judge(int n)
{
int temp = n;
int ans = 0;
while (temp)
{
ans = ans * 10 + (temp % 10);
temp /= 10;
}
if (ans == n)
return 1;
else
return 0;
}
int huiwen(int n)
{
int temp = n;
int ans = 0;
while (temp)
{
ans = ans * 10 + (temp % 10);
temp /= 10;
}
return ans;
}
int main()
{
int n;
int hw;
int t;
int x;
int r[100000];
int i;
while (cin >> n)
{
memset(r, 0, sizeof(r));
x = 0;
while (!judge(n))
{
r[x++] = n;
n += huiwen(n);
}
r[x++] = n;
cout << x-1 << endl;
for (i = 0; i < x; i++)
{
if (i != 0)
{
printf("--->%d", r[i]);
}
else
{
printf("%d", r[i]);
}
}
cout << endl;
}
system("pause");
return 0;
}