c++ 输出控制iomanip
生活随笔
收集整理的這篇文章主要介紹了
c++ 输出控制iomanip
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
2019獨角獸企業(yè)重金招聘Python工程師標準>>>
1輸出精度控制
#include<iostream>
#include?<iomanip>//精度控制相關(guān)頭文件?
using?namespace?std;int?main(){streamsize?prec=cout.precision();?//獲取默認精度???????cout<<"default?precision?size?is?"<<prec<<endl;cout<<setprecision(3);//重設精度?double?x;while(cin>>x){cout<<"the?current?input?x?is?"<<x<<endl;??????????????}cout<<setprecision(prec);//重置默認精度?double?temp=1.3333333;cout<<"the?value?is?"<<temp<<endl;cout<<"end?input!!!!!!!!!!!"<<endl;system("pause");return?0;
} 輸出:
default precision size is 6
1.2345
the current input x is 1.23
123456
the current input x is 1.23e+005
quit
the value is 1.33333
end input!!!!!!!!!!!
轉(zhuǎn)載于:https://my.oschina.net/hnuweiwei/blog/285056
總結(jié)
以上是生活随笔為你收集整理的c++ 输出控制iomanip的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 活动目录服务器(windows serv
- 下一篇: 关于SOAP的几篇文章