import java.util.Scanner;
public class day01{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    boolean boo = true;
    int positiveNumber = 0;//正数
    int negativeNumber = 0;//负数
    while (boo) {
      System.out.println("请输出一个数字:");
      int number = sc.nextInt();
      if (number>0) {
        positiveNumber++;
      }else if (number<0) {
        negativeNumber++;
      }else {
        break;

      }
    }
    System.out.println("正数个数为:"+positiveNumber+"负数个数为:"+negativeNumber);
  }
}

 

版权声明:本文为quangan原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/quangan/p/13341401.html