当前位置:网站首页>HDU 2008 digital statistics

HDU 2008 digital statistics

2022-07-06 21:58:00 Full stack programmer webmaster

Hello everyone , I meet you again , I'm the king of the whole stack .

Number value 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

Statistics given n In number , negative 、 Number of zero and positive numbers .

Input

Multiple groups of input data , One row for each group , The first number in each row is an integer n(n<100), Indicates the number of values to be counted , And then there was n A real number ; hypothesis n=0, Indicates the end of input , This line does not process .

Output

Input data for each group . Output one line a,b and c. Respectively represent the negative numbers in the given data 、 Number of zero and positive numbers .

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

Be careful : You cannot save data in an array , Because the number entered may be decimal . We need to infer 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;
}

Copyright notice : This article is the original article of the blogger , Blog , Do not reprint without permission .

Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/117039.html Link to the original text :https://javaforall.cn

原网站

版权声明
本文为[Full stack programmer webmaster]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207061343425256.html