首页 > 其他 > 详细

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

时间:2020-09-17 23:36:49      阅读:101      评论:0      收藏:0      [点我收藏+]

解决:

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\n",s1,s2,s3);

    }

    return 0;

}

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

原文:https://www.cnblogs.com/Hello-world-hello-lazy/p/13688030.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!