考察一行内的元素输入和获取:
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] str = br.readLine().split(" "); int index = 1; for(String s: str) { if(!s.equals("250")) { index++; } else { System.out.print(index); break; } } } }