当前位置:网站首页>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
边栏推荐
- The underlying implementation of string
- PostgreSQL 安装gis插件 CREATE EXTENSION postgis_topology
- Huawei has launched attacks in many industries at the same time, and its frightening technology has made European and American enterprises tremble
- [Chongqing Guangdong education] Tianjin urban construction university concrete structure design principle a reference
- Web开发小妙招:巧用ThreadLocal规避层层传值
- Leetcode topic [array] -118 Yang Hui triangle
- Univariate cubic equation - relationship between root and coefficient
- 一行代码可以做些什么?
- guava:Collections.unmodifiableXXX创建的collection并不immutable
- [Yu Yue education] higher mathematics of Nanchang University (2) reference materials
猜你喜欢
numpy 下载安装
快讯:飞书玩家大会线上举行;微信支付推出“教培服务工具箱”
Reptile practice (V): climbing watercress top250
基于LM317的可调直流电源
Unity3D学习笔记6——GPU实例化(1)
Aggregate function with key in spark
What can one line of code do?
Z function (extended KMP)
Internet News: Geely officially acquired Meizu; Intensive insulin purchase was fully implemented in 31 provinces
关于char[]数组通过scanf赋值使用上的一些问题。。
随机推荐
一行代码可以做些什么?
Record the process of cleaning up mining viruses
Checkpoint of RDD in spark
R3live notes: image processing section
Why is the cluster mode of spark on Yan better than the client mode
Run the deep network on PI and Jetson nano, and the program is killed
Why does MySQL index fail? When do I use indexes?
[go][reprint]vscode run a HelloWorld example after configuring go
14 years Bachelor degree, transferred to software testing, salary 13.5k
1D convolution detail
Start the embedded room: system startup with limited resources
MySQL removes duplicates according to two fields
AI 企业多云存储架构实践 | 深势科技分享
Why rdd/dataset is needed in spark
通过数字电视通过宽带网络取代互联网电视机顶盒应用
十一、服务介绍及端口
Guava: three ways to create immutablexxx objects
uni-app App端半屏连续扫码
MySQL - 事务(Transaction)详解
Earned value management EVM detailed explanation and application, example explanation