HDU 2008 numerical statistics

Source: Internet
Author: User
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;}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.