hdoj2008解题报告

Problem Description
统计给定的n个数中,负数、零和正数的个数。
 

Input
输入数据有多组,每组占一行,每行的第一个数是整数n(n<100),表示需要统计的数值的个数,然后是n个实数;如果n=0,则表示输入结束,该行不做处理。
 

Output
对于每组输入数据,输出一行a,b和c,分别表示给定的数据中负数、零和正数的个数。
 
#include <cstdio>
#include <cmath>
int main()
{
    int n, m;
    while (scanf("%d %d", &n, &m) != EOF)
    {
        double res = 0;
        double x = n;
        for (int i = 0; i < m; i++)
        {
            res += x;
            x = sqrt(x);
        }
        printf("%.2lf\n", res);
    }
	return 0;
}


posted on 2014-01-21 21:40  冰迹风痕  阅读(98)  评论(0编辑  收藏  举报

导航