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;

    }

  • 相关阅读:
    php扩展开发函数
    python里面的引用
    apk的包名修改
    python3.3中print换行
    Project Euler Problem4
    Project Euler Problem5
    Project Euler Problem3
    通过电脑来访问手机站点——UserAgent和UserDataDir的应用
    LJX的校园:社会实践的任务
    连续和最大
  • 原文地址:https://www.cnblogs.com/2014acm/p/3887422.html
Copyright © 2011-2022 走看看