Article From:https://www.cnblogs.com/huoyuying/p/9734104.html

#include<stdio.h>

int main(){

         int a=0,b=0,c=0,n;

         scanf(“%d”,&n);

         int i,f[100];

         for(i=0;i<n;i++){

                   if(f[i]<0)a++;

                   else if(f[i]==0)b++;

                   else c++;

         }

         printf(“%d %d %d”,a,b,c);

         return 0;

}

 

Problem Description

 

Statistics the number of negative numbers, zeros and positive numbers in a given number of n.

 

 

 

Input

 

There are multiple sets of input data, each of which occupies one row. The first number in each row is an integer n (n< 100), representing the number of values to be counted, followed by N real numbers; if n = 0, the input ends and the line is not processed.

 

 



Output

 

For each set of input data, the output lines a, b, and C represent the number of negative, zero, and positive numbers in the given data, respectively.

 

 



Sample Input

 

6 0 1 2 3 -1 0
5 1 2 3 4 0.5
0

 

 



Sample Output

 

1 2 3
0 0 5

 

Link of this Article: 2008. numerical statistics

Leave a Reply

Your email address will not be published. Required fields are marked *