题解 | #统计数据正负个数#
统计数据正负个数
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); } }