2018/12/08 L1-041 寻找250 Java

考察一行内的元素输入和获取:

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;
            }
        }

    }

}

 

posted @ 2018-12-08 15:52  HHZZHH  阅读(258)  评论(0编辑  收藏  举报