2018/12/08 L1-047 装睡 Java

基础题. 考验BufferedReader和InputStreamReader的使用, 还有写if判断的能力, 在这题中我还使用了foreach来循环遍历ArrayList类的变量, 代码如下:

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int num = Integer.parseInt(br.readLine());
        ArrayList<String[]> alist = new ArrayList<String[]>();
        for(int i=0; i<num; i++) {
            String[] str = br.readLine().split(" ");
            alist.add(str);
        }

        for(String[] a : alist) {
            if(Integer.parseInt(a[1]) < 15 || Integer.parseInt(a[1]) > 20 || Integer.parseInt(a[2]) < 50 || Integer.parseInt(a[2]) > 70) {
                System.out.println(a[0]);
            }
        }

    }

}

猜你喜欢

转载自www.cnblogs.com/huangZ-H/p/10088923.html