当前位置:网站首页>HDU 2008 数字统计
HDU 2008 数字统计
2022-07-06 13:44:00 【全栈程序员站长】
大家好,又见面了,我是全栈君。
号码值统计
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 53462 Accepted Submission(s): 27366
Problem Description
统计给定的n个数中,负数、零和正数的个数。
Input
输入数据有多组,每组占一行,每行的第一个数是整数n(n<100),表示须要统计的数值的个数,然后是n个实数;假设n=0,则表示输入结束,该行不做处理。
Output
对于每组输入数据。输出一行a,b和c。分别表示给定的数据中负数、零和正数的个数。
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注意:不能用数组存数,由于输入的数有可能是小数。要一个一个的推断
#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;
}版权声明:本文博主原创文章,博客,未经同意不得转载。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/117039.html原文链接:https://javaforall.cn
边栏推荐
- 关于程序员的职业操守,从《匠艺整洁之道》谈起
- Fastjson parses JSON strings (deserialized to list, map)
- Shake Sound poussera l'application indépendante de plantation d'herbe "louable", les octets ne peuvent pas oublier le petit livre rouge?
- R language for text mining Part4 text classification
- 中国白酒的5场大战
- Z function (extended KMP)
- Microsoft technology empowerment position - February course Preview
- guava:创建immutableXxx对象的3种方式
- ViT论文详解
- Torch Cookbook
猜你喜欢

基于LM317的可调直流电源

Reptile practice (V): climbing watercress top250

Basic introduction of figure

LeetCode:1189. The maximum number of "balloons" -- simple

Quick news: the flybook players' conference is held online; Wechat payment launched "education and training service toolbox"

Digital transformation takes the lead to resume production and work, and online and offline full integration rebuilds business logic

PostgreSQL 修改数据库用户的密码

缓存更新策略概览(Caching Strategies Overview)

C# 如何在dataGridView里设置两个列comboboxcolumn绑定级联事件的一个二级联动效果

PostgreSQL 安装gis插件 CREATE EXTENSION postgis_topology
随机推荐
技术分享 | 抓包分析 TCP 协议
c语言char, wchar_t, char16_t, char32_t和字符集的关系
首批入选!腾讯安全天御风控获信通院业务安全能力认证
Why rdd/dataset is needed in spark
1D convolution detail
Huawei has launched attacks in many industries at the same time, and its frightening technology has made European and American enterprises tremble
C language: comprehensive application of if, def and ifndef
Yyds dry goods inventory C language recursive implementation of Hanoi Tower
FZU 1686 龙之谜 重复覆盖
Uni app app half screen continuous code scanning
MySQL removes duplicates according to two fields
Is it important to build the SEO foundation of the new website
Four common ways and performance comparison of ArrayList de duplication (jmh performance analysis)
Numpy download and installation
一行代码可以做些什么?
缓存更新策略概览(Caching Strategies Overview)
Fastjson parses JSON strings (deserialized to list, map)
Quick news: the flybook players' conference is held online; Wechat payment launched "education and training service toolbox"
numpy 下载安装
ROS error: could not find a package configuration file provided by "move_base“