题解 | #统计数据正负个数#

统计数据正负个数

http://www.nowcoder.com/practice/3f33889582934a09b4e3ddd3cc976226

import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a=new int[10];
        int positive=0,negative=0;
        for(int i=0;i<10;i++)
        {
            a[i]=sc.nextInt();
            if(a[i]>0)
            {
                positive++;
            }else{
                negative++;
            }
        }
        System.out.println("positive:"+positive+"\n"+"negative:"+negative);
    }
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
06-25 19:15
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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