当前位置:网站首页>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
边栏推荐
- Hill | insert sort
- Binary tree node at the longest distance
- Guava: three ways to create immutablexxx objects
- 通过数字电视通过宽带网络取代互联网电视机顶盒应用
- 用aardio写一个旋转验证码标注小工具
- Four common ways and performance comparison of ArrayList de duplication (jmh performance analysis)
- VIM basic configuration and frequently used commands
- The golden age of the U.S. technology industry has ended, and there have been constant lamentations about chip sales and 30000 layoffs
- Digital transformation takes the lead to resume production and work, and online and offline full integration rebuilds business logic
- Intelligent online customer service system source code Gofly development log - 2 Develop command line applications
猜你喜欢

Huawei has launched attacks in many industries at the same time, and its frightening technology has made European and American enterprises tremble

Checkpoint of RDD in spark

Basic introduction of figure

PostgreSQL install GIS plug-in create extension PostGIS_ topology

It's not my boast. You haven't used this fairy idea plug-in!

【力扣刷题】一维动态规划记录(53零钱兑换、300最长递增子序列、53最大子数组和)

【MySQL】Online DDL详解

PostgreSQL modifies the password of the database user

C how to set two columns comboboxcolumn in DataGridView to bind a secondary linkage effect of cascading events

MPLS experiment
随机推荐
1D convolution detail
JS method to stop foreach
Efficiency tool +wps check box shows the solution to the sun problem
Depth first traversal (DFS) and breadth first traversal (BFS)
The role of applicationmaster in spark on Yan's cluster mode
PostgreSQL modifies the password of the database user
Redistemplate common collection instructions opsforhash (IV)
1292_ Implementation analysis of vtask resume() and xtask resume fromisr() in freeros
十一、服务介绍及端口
guava:Collections. The collection created by unmodifiablexxx is not immutable
基于LM317的可调直流电源
ROS error: could not find a package configuration file provided by "move_base“
Method return value considerations
Technology sharing | packet capturing analysis TCP protocol
在Pi和Jetson nano上运行深度网络,程序被Killed
Record the process of cleaning up mining viruses
Dialogue with Jia Yangqing, vice president of Alibaba: pursuing a big model is not a bad thing
Reptile practice (V): climbing watercress top250
14年本科毕业,转行软件测试,薪资13.5K
关于char[]数组通过scanf赋值使用上的一些问题。。