函数介绍
头文件: iomanip
setiosflags(ios::fixed):表示控制小数点右边的数字个数,需要与下面的函数组合使用。
setprecision(n):表示可控制输出流的数字个数。
代码例子
#include<bits/stdc++.h>
using namespace std;
int main(){
double s = 1.23456789;
cout<<setprecision(4)<<s<<endl;
cout<<setiosflags(ios::fixed)<<setprecision(4)<<s<<endl;
return 0;
}
Comments | NOTHING