c++几个重要的问题

版权声明:版权所有,转载请标明 https://blog.csdn.net/zxwsbg/article/details/81736781

setprecision(n) 表示输出总共n位

cout<<setiosflags(ios::fixed)

先写这个,就变成了保留n位小数。

也可以直接用cout<<fixed<<setpricision(n)<<endl;


cout<<ceil(a)<<endl;   //向上取整
cout<<floor(a)<<endl;   //向下取整
cout<<round(a)<<endl;   //四舍五入

猜你喜欢

转载自blog.csdn.net/zxwsbg/article/details/81736781
今日推荐