zoukankan      html  css  js  c++  java
  • c++ 保留小数

    precision()

    #include<iostream>
    using namespace std;
    
    int main()
    {
    float s=11.201    ;
    
    cout.precision(2);
                
    cout <<s<<endl;
    return 0;
    }
    View Code
    View Code

    #include<iostream>

    using namespace std;

    int main()

    {      float s=11.201 ;

    cout.precision(2);        

         cout <<s<<endl;

    return 0;

    }

     

    #include<iostream>
    using namespace std;
    
    
    int main()
    {
        ;
    float t=10001.119;
    cout.precision(2);
                
    cout <<t<<endl;
    return 0;
    }
    View Code

    #include<iostream>

    using namespace std;

    int main()

    {  

    float t=10001.119;

    cout.precision(2);   

              cout <<t<<endl;

    return 0;

    }

    *******************************************************************************************************************************************

    #include<iostream>
    using namespace std;
    
    int main()
    {
    float s=11.201    ;
    
    cout.precision(2);
     cout.setf(ios::fixed);           
    cout <<s<<endl;
    return 0;
    }
    View Code

    #include<iostream>
    using namespace std;
    
    
    int main()
    {
        ;
    float t=10001.119;
    cout.precision(2);
        cout.setf(ios::fixed);        
    cout <<t<<endl;
    return 0;
    }
    View Code

    ****************************************************************************************************************************************************

    #include<iostream>
    using namespace std;
    
    
    int main()
    {
        
    float s=11.201;
    
    cout<<fixed;    
    cout.precision(2);
            
    cout <<s<<endl;
    return 0;
    }
    View Code

    #include<iostream>
    using namespace std;
    
    
    int main()
    {
        
    float t=10001.119;
    cout<<fixed;    
    cout.precision(2);
                  
    cout <<t<<endl;
    return 0;
    }
    View Code

    *****************************************************************************************************************************************************

    #include<iostream>
    #include <iomanip>
    using namespace std;
    
    
    int main()
    {
        
    float s=11.201;
    
    cout<<fixed<<setprecision(2) <<s<<endl;   
    
            
    
    return 0;
    }
    View Code

    #include<iostream>

    #include <iomanip>

    using namespace std;

    int main()

    {  

    float s=11.201;

    cout<<fixed<<setprecision(2) <<s<<endl;  

           

    return 0;

    }

    #include<iostream>
    #include <iomanip>
    using namespace std;
    
    
    int main()
    {
        
    float t=10001.119;
    
    cout<<fixed<<setprecision(2) <<t<<endl;   
    
            
    
    return 0;
    }
    View Code

    #include<iostream>

    #include <iomanip>

    using namespace std;

    int main()

    {  

    float t=10001.119;

    cout<<fixed<<setprecision(2) <<t<<endl;  

           

    return 0;

    }

  • 相关阅读:
    eclipse的maven配置及本地仓库配置
    协方差矩阵计算方法
    马氏距离
    Python中的相对路径
    Pytorch中的LSTM和LSTMCell
    The Unreasonable Effectiveness of Recurrent Neural Networks
    RNN的灵活性
    LSTM和GRU
    Nesterov Accelerated Gradient
    Wasserstein GAN最新进展:从weight clipping到gradient penalty,更加先进的Lipschitz限制手法
  • 原文地址:https://www.cnblogs.com/2014acm/p/3887422.html
Copyright © 2011-2022 走看看