首页 > 其他 > 详细

P2393 yyy loves Maths II

时间:2017-10-21 10:00:51      阅读:325      评论:0      收藏:0      [点我收藏+]

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;
}

 

P2393 yyy loves Maths II

原文:http://www.cnblogs.com/war1111/p/7703558.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!