直接上代码吧。
#include<iostream>
#include<iomanip>///输出流头文件
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cout<<123.0<<endl;
cout<<showpoint<<123.0000<<endl;///显示小数
cout<<noshowpoint<<123.0<<endl;
cout.width(10);cout<<123<<endl;
cout<<setw(10)<<"123"<<endl;///设置宽度,两种方式均可
cout<<fixed<<setprecision(2)<<1234.5678<<endl;;///输出所要精度小数
cout<<setfill('0')<<setw(10)<<12.34<<endl;///不够位数的前面填充字符
return 0;
}