题解 | #统计输入正数个数#
统计输入正数个数
http://www.nowcoder.com/practice/3266386e460a4e219d6b7d0bed2065b9
import java.util.*;
public class Main { public static void main(String[] args) { int count = 0; Scanner scanner = new Scanner(System.in);
//write your code here......
//注意把变量放进循环里
while(true){
int a=scanner.nextInt();
if(a>0){
count++;
}else{
break;
}
}
System.out.println(count);
}
} //写个死循环一直判断,错误就退出