c++ 如何输出大数不用科学计数法 和如何保留几位小数输出

来源:互联网 发布:基层网络写手无收入 编辑:程序博客网 时间:2024/05/20 20:58
#include <string>#include <cstring>#include <cmath>#include <algorithm>#include <iostream>#include <cstdio>#include <iomanip>using namespace std;int main(){    int n ;    while(cin >> n && n)    {      //  cout << std::fixed;        std::cout << std::fixed;<span style="white-space:pre"></span>//不用科学计数法        std::cout.precision(0);<span style="white-space:pre"></span>//保留一位小数
<span style="white-space:pre"></span>//cout << setprecision(3) << endl;        cout << pow(3.0 , n) << endl;    }    return 0;}

0 0
原创粉丝点击