Description
Counts the number of negative, 0, and positive numbers in a given n number
Input
There are several groups of input data, one row per group, the first number of each row is an integer n (n<100), the number of values that need to be counted, and then n real numbers, and if n=0, that line is not processed.
Output
For each set of input data, the output line, a, B, and C, respectively, indicates the number of negative, 0, and positive numbers in the given data.
Sample Input6 0 1 2 3-1 1 2 3 4 0.50Sample Output1 2 0 5HINT
Source
#include <stdio.h>int main () {int n,a[100][3]; float x; int i=0,j; scanf ("%d", &n); while (n!=0) { a[i][0]=a[ i][1]=a[i][2]=0; for (j=0;j<n;j++) { scanf ("%f", &x); if (x<0) a[i][0]++; else if (x==0) a[i][1]++; else a[i][2]++; } scanf ("%d", &n); i++; } for (j=0;j<i;j++) printf ("%d%d%d\n", a[j][0],a[j][1],a[j][2]);}
Copyright NOTICE: This article is the original blogger articles, reproduced please indicate the source.
Zzuli OJ 1083: Numerical statistics (multi-instance testing)