C++输出有效数字位数

来源:互联网 发布:淘宝助理菜鸟组件 编辑:程序博客网 时间:2024/05/01 04:57
<span style="font-size:18px;">cout.setf(ios::fixed);</span>

例子:

#include <iostream>#define PI 3.14159265358979323using namespace std;int main(){    int r;    cin>>r;    double s;    s = r*r*PI;    cout.precision(7);    cout<<s<<endl;    return 0;}
输入:4

输出:50.26548

0 0