当前位置:网站首页>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
边栏推荐
- Z function (extended KMP)
- Huawei has launched attacks in many industries at the same time, and its frightening technology has made European and American enterprises tremble
- Leveldb source code analysis series - main process
- [daily] win10 system setting computer never sleeps
- What is the RDD operator in spark
- JPEG2000-Matlab源码实现
- JS learning notes OO create suspicious objects
- b站视频链接快速获取
- [Chongqing Guangdong education] Tianjin urban construction university concrete structure design principle a reference
- Five wars of Chinese Baijiu
猜你喜欢
Why rdd/dataset is needed in spark
1292_ Implementation analysis of vtask resume() and xtask resume fromisr() in freeros
Aggregate function with key in spark
[asp.net core] set the format of Web API response data -- formatfilter feature
MPLS experiment
Quick news: the flybook players' conference is held online; Wechat payment launched "education and training service toolbox"
抖音将推独立种草App“可颂”,字节忘不掉小红书?
[Yu Yue education] higher mathematics of Nanchang University (2) reference materials
互联网快讯:吉利正式收购魅族;胰岛素集采在31省全面落地
Shake Sound poussera l'application indépendante de plantation d'herbe "louable", les octets ne peuvent pas oublier le petit livre rouge?
随机推荐
Internet News: Geely officially acquired Meizu; Intensive insulin purchase was fully implemented in 31 provinces
Microsoft technology empowerment position - February course Preview
Basic introduction of figure
语谱图怎么看
用aardio写一个旋转验证码标注小工具
Caching strategies overview
[Digital IC manual tearing code] Verilog automatic beverage machine | topic | principle | design | simulation
The role of applicationmaster in spark on Yan's cluster mode
Yuan Xiaolin: safety is not only a standard, but also Volvo's unchanging belief and pursuit
美国科技行业结束黄金时代,芯片求售、裁员3万等哀声不断
Search map website [quadratic] [for search map, search fan, search book]
Checkpoint of RDD in spark
Set up a time server
缓存更新策略概览(Caching Strategies Overview)
NPM run dev start project error document is not defined
Proxy and reverse proxy
Sql: stored procedures and triggers - Notes
guava:创建immutableXxx对象的3种方式
Guava: three ways to create immutablexxx objects
One line by line explanation of the source code of anchor free series network yolox (a total of ten articles, you can change the network at will after reading it, if you won't complain to me)