2012/02/12

[zerojudge] a002 簡易加法

題目:https://zerojudge.tw/ShowProblem?problemid=a002
說明:簡單數字的加法,讀取 stdin 後,用空白來拆開數字,最後將數字相加。

Java 版
import java.util.Scanner;

public class A002 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String [] str;
        while (in.hasNext()) {
            str = in.nextLine().split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[1]);
            System.out.println(a + b);
        }
    }
}
Python 版 (2022.06)
a, b = (input().split())
a = int(a)
b = int(b)
print(a + b)

沒有留言:

張貼留言