2012/02/22

[zerojudge] d064 ㄑㄧˊ 數?

題目:https://zerojudge.tw/ShowProblem?problemid=d064
說明:奇數及偶數的判斷,對 2 取餘數。

Java 版
import java.util.Scanner;

public class D064 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int a = Integer.parseInt(in.nextLine());
            if(a % 2 == 0)
                System.out.println("Even");
            else
                System.out.println("Odd");
        }
    }
}
Python 版 (2022.07)
a = int(input())
if a % 2 == 0:
    print('Even')
else:
    print('Odd')

沒有留言:

張貼留言