hdu 2008 数值统计

数值统计

 思路:分为正数,负数,0,三类,然后分别统计

代码:

#include<iostream>
using namespace std;
int main()
{
    int n;
    double num;
    int a, b, c;
    while (cin >> n&&n)
    {
        a = b = c = 0;
        while (n--)
        {
            cin >> num;
            if (num > 0)
            {
                a++;
            }
            if (num == 0)
            {
                b++;
            }
            if (num < 0)
            {
                c++;
            }
        }
        cout << c << " " << b << " " << a << endl;
    }


    system("pause");
    return 0;
}
原文地址:https://www.cnblogs.com/pcdl/p/12250382.html