zzulioj 1045: Numerical statistics

Title description
Count the number of negative, zero and positive numbers among the given n numbers.

Input
The first number entered is an integer n (n<100), which means the number of values ​​to be counted, and then n integers

Output
Output a line of a, b and c, respectively representing the number of negative, zero and positive numbers in the given data.

Sample input Copy
6 0 1 2 3 -1 0
Sample output Copy
1 2 3
prompt
...

#include<stdio.h>
int main()
{
    
    
	int n,a,b,c,m;
	a=0;b=0;c=0;
	scanf("%d",&n);
	while(n--)
	{
    
    
		scanf("%d",&m);
		if(m<0)
		  a++;
		  if(m==0)
		    b++;
		    if(m>0)
		      c++;
	}
	printf("%d %d %d\n",a, b, c);
	return 0;
}

Guess you like

Origin blog.csdn.net/m0_53024529/article/details/112980450