题目:
6 0 1 2 3 -1 0 5 1 2 3 4 0.5 0
1 2 3 0 0 5
题目分析:
简单题。
代码如下:
/*
* h.cpp
*
* Created on: 2015年3月20日
* Author: Administrator
*
* hdu 2008
*/
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
int n;
while(scanf("%d",&n)!=EOF,n){
int zero_num = 0;
int negaive_num = 0;
int positive_num = 0;
int i;
double temp;
for(i = 0 ; i < n ; ++i){
scanf("%lf",&temp);
if(temp == 0){
zero_num++;
}else if(temp < 0){
negaive_num++;
}else{
positive_num++;
}
}
printf("%d %d %d\n",negaive_num,zero_num,positive_num);
}
return 0;
}
(hdu 简单题 128道)hdu 2008 数值统计(统计一列数中正数、负数、0的个数)
原文:http://blog.csdn.net/hjd_love_zzt/article/details/44538825