题解 | #统计数据正负个数#
统计数据正负个数
https://www.nowcoder.com/practice/3f33889582934a09b4e3ddd3cc976226
import java.util.Arrays; import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String str[] = in.nextLine().split(" "); int count_1=0; int count_2=0; for(int i=0;i<10;i++){ int m= Integer.parseInt(str[i]); if(m>0){ count_1++; }else if(m==0){ }else{ count_2++; } } System.out.printf("positive:%d\nnegative:%d",count_1,count_2); } }