当前位置:网站首页>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)
- Tips for web development: skillfully use ThreadLocal to avoid layer by layer value transmission
- Why does MySQL index fail? When do I use indexes?
- [asp.net core] set the format of Web API response data -- formatfilter feature
- ViT论文详解
- R language for text mining Part4 text classification
- Aggregate function with key in spark
- 跨分片方案 总结
- Redistemplate common collection instructions opsforlist (III)
- 功能强大的国产Api管理工具
猜你喜欢
It's not my boast. You haven't used this fairy idea plug-in!
Tiktok will push the independent grass planting app "praiseworthy". Can't bytes forget the little red book?
[Li Kou brush questions] 32 Longest valid bracket
跨分片方案 总结
Dialogue with Jia Yangqing, vice president of Alibaba: pursuing a big model is not a bad thing
1292_ Implementation analysis of vtask resume() and xtask resume fromisr() in freeros
Method return value considerations
[Yu Yue education] higher mathematics of Nanchang University (2) reference materials
袁小林:安全不只是标准,更是沃尔沃不变的信仰和追求
1292_FreeROS中vTaskResume()以及xTaskResumeFromISR()的实现分析
随机推荐
Enhance network security of kubernetes with cilium
ViT论文详解
基于LM317的可调直流电源
Shake Sound poussera l'application indépendante de plantation d'herbe "louable", les octets ne peuvent pas oublier le petit livre rouge?
ROS error: could not find a package configuration file provided by "move_base“
Redistemplate common collection instructions opsforset (V)
MySQL - 事务(Transaction)详解
对话阿里巴巴副总裁贾扬清:追求大模型,并不是一件坏事
Michael smashed the minority milk sign
[Li Kou brushing questions] one dimensional dynamic planning record (53 change exchanges, 300 longest increasing subsequence, 53 largest subarray and)
Description of web function test
jvm:大对象在老年代的分配
技术分享 | 抓包分析 TCP 协议
Sparkshuffle process and Mr shuffle process
袁小林:安全不只是标准,更是沃尔沃不变的信仰和追求
b站视频链接快速获取
Huawei has launched attacks in many industries at the same time, and its frightening technology has made European and American enterprises tremble
Happy sound 2[sing.2]
新入职一家公司需要去实践和注意的内容
麦趣尔砸了小众奶招牌