解题思路:
注意事项:
参考代码:
#include<iostream>
using namespace std;
int main()
{
int x, sum = 10, a = 1;
cin >> x;
while (true) //求位数
{
if (x / sum == 0)
{
break;
}
sum = sum * 10;
a++;
}
cout << a << endl;
int j = a;
int x1 = x;
for (a; a > 0; a--) //求每一位数
{
cout << x / (sum / 10) << " ";
x = x % (sum / 10);
sum = sum / 10;
}
cout << endl;
for (int i = 0; i < j; i++) //倒叙输出这个数
{
cout << x1 % 10;
x1 = x1 / 10;
}
cout << endl;
return 0;
}
0.0分
1 人评分