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

 

posted @ 2020-02-01 21:58  PCDL&TIPO  阅读(133)  评论(0编辑  收藏  举报