问题 范例: 输入3个整数,输出它们的1次幂、2次幂和3次幂。
#include <iomanip>
using namespace std;
int main ()
{int a, b,c;
cin >> a >> b >> c;
cout.fill (' ');// 不满足位宽的数字用 0 补齐
cout<< left << setw(9)<< a<< setw(9) << a*a<< setw(9) << a*a*a << endl;// 左对齐
cout<< left << setw(9) << b << setw(9)<< b*b << setw(9) << b*b*b << endl;// 左对齐
cout<< left << setw(9) << c<< setw(9) << c*c << setw(9) << c*c*c << endl;// 左对齐
return 0;
}
1 5 100
1 1 1
5 25 125
100 10000 1000000
Process returned 0 (0x0) execution time : 4.393 s
Press any key to continue.