1 public static void main(String[] args) { 2 Scanner sc=new Scanner(System.in); 3 System.out.println("请开始输入"); 4 int input=sc.nextInt(); 5 int zhengshu=0; 6 int fushu=0; 7 while(input!=0){ 8 if(input>0){ 9 zhengshu++; 10 }else{ 11 fushu++; 12 } 13 input=sc.nextInt(); 14 } 15 16 System.out.println("正数:"+zhengshu+"个,负数:"+fushu+"个"); 17 }
时间: 2024-10-18 05:02:52