zoukankan      html  css  js  c++  java
  • P2393 yyy loves Maths II

    P2393 yyy loves Maths II
    long double
    比如保留5位小数
    *1000000都变成整数
    最后再/1000000避免精度误差
    scanf("%Lf",&x);
    printf("%.Lf",x);

    #include<iostream>
    #include<cstdio>
    #include<queue>
    #include<algorithm>
    #include<cmath>
    #include<ctime>
    #include<cstring>
    #define inf 2147483647
    #define For(i,a,b) for(register int i=a;i<=b;i++)
    #define p(a) putchar(a)
    #define g() getchar()
    //by war
    //2017.10.21
    using namespace std;
    long double sum,x,t=1000000;
    
    void in(int &x)
    {
        int y=1;
        char c=g();x=0;
        while(c<'0'||c>'9')
        {
        if(c=='-')
        y=-1;
        c=g();
        }
        while(c<='9'&&c>='0')x=x*10+c-'0',c=g();
        x*=y;
    }
    void o(int x)
    {
        if(x<0)
        {
            p('-');
            x=-x;
        }
        if(x>9)o(x/10);
        p(x%10+'0');
    }
    int main()
    {
    //    freopen("t.in","r",stdin);
    //    freopen("t.out","w",stdout);
        while(scanf("%LF",&x)!=EOF)
        sum+=x*t;
        printf("%.5LF",sum/t);
         return 0;
    }
  • 相关阅读:
    IE8、IE9解决浏览器跨域。
    英语写作-Introduction
    qt添加图标
    Qt 编译错误 :cannot find file .pro
    python
    数据集
    基金
    visio2010求交操作
    书籍网站
    ROS安装xtion
  • 原文地址:https://www.cnblogs.com/war1111/p/7703558.html
Copyright © 2011-2022 走看看