Numerical statistics
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 53462 accepted submission (s): 27366
Problem description counts the number of negative, zero, and positive numbers in the given N number.
There are multiple groups of input data. Each group occupies one row. The first number of each row is an integer n (n <100), which indicates the number of values to be counted, followed by n real numbers; if n = 0, the input is over and the row is not processed.
Output outputs a row of A, B, and C for each group of input data, indicating the number of negative, zero, and positive numbers in the given data respectively.
Sample Input
6 0 1 2 3 -1 05 1 2 3 4 0.50
Sample output
1 2 30 0 5
Note: The number of input values cannot be stored in arrays, because the number of input values may be decimals, which must be determined one by one.
#include<stdio.h>int main(){int n;while(scanf("%d",&n),n){int i,j,a=0,b=0,c=0; double s;for(i=0;i<n;i++){scanf("%lf",&s);{if(s<0) a++;else if(s==0) b++;else if(s>0) c++;}}printf("%d %d %d",a,b,c);printf("\n");}return 0;}