2012/02/22

[zerojudge] d063 0與1

題目:https://zerojudge.tw/ShowProblem?problemid=d063
說明:邏輯運算子的使用。

Java 版
import java.util.Scanner;
 
public class D063 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in); 
        while (in.hasNext()) {
            int a = Integer.parseInt(in.nextLine());
            System.out.println(a ^ 1);
        }
    }
}
Python 版 (2022.07)
a = int(input())
print(a ^ 1)

沒有留言:

張貼留言