#include
1. 控制小数点位数
cout<<setprecision(m)<<n;//若n为浮点数,可控制输出m位小数
2. 整数补零加固定小数点位数
cout<<fixed<<setprecision(m)<<n;//若n为正数,fixed可将整数小数点后补齐零补m个零
3. 输出数据尾部对齐
cout<<setw(m)<<n;//尾部对齐,m为最多可让最后一位对其的位数
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
long long int x;
cin >> x;
for (int n = 1; n <= 40; n++)
{
cout<< setw(15) <<2*x ;
x = 2*x;
if (n % 5 == 0) cout<<endl;
}
}
此刻我让m=15,白色位数一共15