半文件式输入中一种常见的输入方式

解决:

5 1 2 3 4 5式输入的问题(第一个5表示后面需要输入的个数)

#include <iostream>

#include <cstdio>

#include <cmath>

using namespace std;

int main()

{

    int n;

    while(scanf("%d",&n)!=EOF && n!=0)  //先读入一个表示后面需要读入的个数

    {

        int s1=0,s2=0,s3=0;

        for(int i=0;i<n;i++)    //读n次,把后面的读完

        {

            double a;

            scanf("%lf",&a);

            if(a<0.0) s1++;

            if(fabs(a)<10e-6) s2++;

            if(a>0.0) s3++;

        }

        printf("%d %d %d ",s1,s2,s3);

    }

    return 0;

}

这篇文章,是又一个故事的结束...
lazy's story is continuing.
原文地址:https://www.cnblogs.com/Hello-world-hello-lazy/p/13688030.html