P35.3.编写一个程序。要求输入一个5位正整数,然后分解出它的每位数字,并将这些数字按间隔2个空格的逆序形式打印输出。例如,用户输入42339,则程序输出如下结果:
9 3 3 2 4
#include<iostream>
#include<iomanip>
using namespace std;
int main() {
int x, a, b, c, d, e;
cout << "请输入任意一个五位数" << endl;
cin >> x;
e = x % 10;
d = x % 100 / 10;
c = x % 1000 / 100;
b = x % 10000 / 1000;
a = x / 10000;
cout << e << setw(2) << d << setw(2) << c << setw(2) << b << setw(2) << a << endl;
}
使用setw(int)需使用头文件 #include