博客
关于我
杭电oj 2008 java实现
阅读量:490 次
发布时间:2019-03-07

本文共 624 字,大约阅读时间需要 2 分钟。

#杭电oj 2008 java

数值统计

统计给定的n个数中,负数,零和正数的个数。
import java.util.*;public class Main {   	public static void main(String[] args) {   		Scanner sc=new Scanner(System.in);		while(sc.hasNext()) {   			int first=sc.nextInt();//排头,表示数字的个数			if(first==0) break;//如果n=0,则表示输入结束			int positiveNumber=0;//正数个数			int negativeNumber=0;//负数个数			int zeroNumber=0;//零的个数			double[] arr=new double[first];			for(int i=0;i
0) { //是正数 positiveNumber++; }else if(arr[i]<0) { //是负数 negativeNumber++; } else { //是零 zeroNumber++; } } System.out.println(negativeNumber+" "+zeroNumber+" "+positiveNumber); } }}

转载地址:http://fnjcz.baihongyu.com/

你可能感兴趣的文章
NextGen Mirth Connect XStream反序列化远程代码执行漏洞(CVE-2023-43208)
查看>>
next项目部署到服务器pm2进程守护
查看>>
nexus 介绍
查看>>
nexus上传jar
查看>>
Nexus指南中的更新强调集成和透明度的重要性
查看>>
Nexus指南已经发布
查看>>
Nexus(1):Nexus的安装与配置
查看>>
NFC技术:概述
查看>>
NFinal学习笔记 02—NFinalBuild
查看>>
NFS
查看>>
nfs mount 故障 mount.nfs: access denied by server while mounting 10.0.100.208:/backup_usb
查看>>
NFS Server及Client配置与挂载详解
查看>>
NFS 服务配置篇
查看>>