题解 | #统计输入正数个数#
统计输入正数个数
https://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...... int i = 1;//定义一个变量i大于1 while(i > 0){ //假如while>0的情况 int value = scanner.nextInt();//定义一个获取整数为用户输入的数 if(value<=0){ //如果这个数小于0则为非正数 System.out.println(count);//就输出count break;//并跳出 } count++;//count就自增一次 } } }