判断输入的数,正数多少个。负数多少个, 到零时退出程序

 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 }

 

posted on 2017-05-26 11:21  Haol_陈  阅读(180)  评论(0)    收藏  举报