zoukankan      html  css  js  c++  java
  • 半文件式输入中一种常见的输入方式

    解决:

    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.
  • 相关阅读:
    2
    作业5
    实验十
    作业 5 指针应用
    九九乘法表
    实验七(课堂练习)
    实验六 数组 (2)
    实验六 数组
    课堂实验5(求从m到n之间(包括m和n)所有素数的和)
    课堂实验5-2
  • 原文地址:https://www.cnblogs.com/Hello-world-hello-lazy/p/13688030.html
Copyright © 2011-2022 走看看