c++输出流的一些控制

来源:互联网 发布:sql server 2000 4in1 编辑:程序博客网 时间:2024/06/05 16:40

直接上代码吧。

#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;}


0 0
原创粉丝点击