题解 | #统计输入正数个数#
统计输入正数个数
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); while(true){ String s = scanner.nextLine(); String[] ss = s.split(" "); for(String sss : ss){ if(sss.matches("^[0-9]*$") && !sss.equals("0")){ count+=1; }else{ break; } } break; } System.out.print(count); } }