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

问题 1061: C二级辅导-计负均正

时间:2017-06-28 10:50:34      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:else   入口   for   ble   argc   int   www   返回   nbsp   

/********************************************************************
@file     Main.cpp
@date     2017-6-28 09:58:32
@author   Zoro_Tiger
@brief    问题 1061: C二级辅导-计负均正
          http://www.dotcpp.com/oj/problem1061.html
********************************************************************/
//!头文件
#include <cstdio>
#include <cmath>

//!程序入口
int main(int argc, const char* argv[])
{
    //!计算
    double sum = 0, temp = 0, count = 0;
    for (int i = 0; i < 20; ++i)
    {
        scanf("%lf", &temp);
        if (temp <= 0)
        {
            ++count;
        }
        else
        {
            sum += temp;
        }
    }

    //!输出结果
    printf("%d\n", static_cast<int>(count));
    printf("%.2lf\n", sum / (20.0 - count));

    //!返回系统
    return 0;
}

 

问题 1061: C二级辅导-计负均正

标签:else   入口   for   ble   argc   int   www   返回   nbsp   

原文地址:http://www.cnblogs.com/roronoa-zoro-zrh/p/7088469.html

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