2012/02/23

[zerojudge] d066 上學去吧!

題目:https://zerojudge.tw/ShowProblem?problemid=d066
說明:if/else 的關係練習,Python 的大於小於比較式,可以寫在一起,大驚奇。

Java 版
import java.util.Scanner;

public class D066 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String input = in.nextLine();
            String[] time = input.split(" ");
            int h = Integer.parseInt(time[0]);
            int m = Integer.parseInt(time[1]);
            if(h >= 7 && h <= 16){
                if(h == 7 && m < 30)
                    System.out.println("Off School");
                else
                    System.out.println("At School");
            }
            else
                System.out.println("Off School");
        }
    }
}
Python 版 (2022.07)
h, m = map(int, input().split(' '))
if 7 <= h <= 16:
    if h == 7 and m < 30:
        print('Off School')
    else:
        print('At School')
else:
    print('Off School')

沒有留言:

張貼留言