링크 https://www.acmicpc.net/problem/1000
문제 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.
입력 첫째 줄에 A와 B가 주어진다. (0 < A, B < 10)
출력 첫째 줄에 A+B를 출력한다.

 

Python 3

num = input().split()
a = int(num[0])
b = int(num[1])
print(a + b)
a, b = map(int, input().split())
print(a + b)

 

Kotlin (JVM)

import java.util.Scanner

fun main(args: Array<String>) {
    val sc: Scanner = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    println(a + b)
}
fun main() {
    val input = readLine()?.split(" ")
    if (!input.isNullOrEmpty()) {
        val a = input[0].toInt()
        val b = input[1].toInt()
        println(a + b)
    }
}

 

node.js

const fs = require("fs");
const input = fs.readFileSync("/dev/stdin").toString().split(" ");
var a = parseInt(input[0]);
var b = parseInt(input[1]);
console.log(a + b);
const readline = require("readline");

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.on("line", function(line) {
    input = line.split(" ");
    let a = parseInt(input[0]);
    let b = parseInt(input[1]);
    console.log(a + b);
}).on("close", function() {
    process.exit();
});

+ Recent posts