2018/12/08 L1-044 稳赢 Java

基础题, 考察对题目的理解, 考察写if()条件的能力, 代码如下:

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));
        int num = Integer.parseInt(br.readLine());
        while(true) {
//            String str = br.readLine();
//            if(str.equals("end")) {
//                return;
//            } else {
//                
//            }
            for(int i=0; i<num; i++) {
                String str = br.readLine();
                if(str.equals("End")) {
                    return;
                } else {
                    if( str.equals("ChuiZi")) {
                        System.out.println("Bu");
                    } else if( str.equals("JianDao")) {
                        System.out.println("ChuiZi");
                    } else if( str.equals("Bu")) {
                        System.out.println("JianDao");
                    } else {
                        return;
                    }
                }
            }
            String str = br.readLine();
            if(str.equals("End")) {
                return;
            } else {
                System.out.println(str);
            }
        }
    }

}

猜你喜欢

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