题解 | #统计输入正数个数#

统计输入正数个数

https://www.nowcoder.com/practice/3266386e460a4e219d6b7d0bed2065b9

import java.util.*;

public class Main {
    public static void main(String[] args) {
        //write your code here......
        Scanner sc=new Scanner(System.in);
	  //定义集合保存元素,遇到0停止添加,返回集合长度-1
        ArrayList<Integer> arr=new ArrayList<Integer>();

        while(true){
            int c=sc.nextInt();
            arr.add( c);
            if(c<=0)break;
        }
        System.out.println(arr.size()-1);

        

    }
}

全部评论

相关推荐

点赞 评论 收藏
分享
05-27 14:57
西北大学 golang
强大的社畜在走神:27届真不用急,可以搞点项目、竞赛再沉淀沉淀,我大二的时候还在天天打游戏呢
投递华为等公司10个岗位
点赞 评论 收藏
分享
Rena1ssanc...:对的,要是面评没太烂,勤更新简历等捞就行了,腾讯可以无限复活
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务