码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 4493 Tutor(精度处理)

时间:2014-07-09 14:15:30      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   art   

题目

 

 

 

bubuko.com,布布扣
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
#include<stdio.h>
int main()
{
    int t;
    double a,s;
    scanf("%d",&t);
    while(t--)
    {
        s=0;
        for(int i=0;i<12;i++)
        {
            scanf("%lf",&a);
            s+=a;
        }
        //1.注意案例的输出格式
        //2.rounded to the nearest penny

        int ss=s/12.0+0.005;
        printf("$%d",ss);
        int yi,er,shu;
        shu=(s/12.0+0.005)*100;
        yi=shu%100/10;er=shu%10;
        if(yi!=0||er!=0)
        {
            printf(".");
            if(yi!=0&&er==0)
                printf("%d",yi);
            else
                printf("%d%d",yi,er);
        }
        puts("");
    }
    return 0;
}
View Code

 

HDU 4493 Tutor(精度处理),布布扣,bubuko.com

HDU 4493 Tutor(精度处理)

标签:style   blog   http   color   os   art   

原文地址:http://www.cnblogs.com/laiba2004/p/3832457.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!