A+B - 7 (11021)

Created:

Baekjoon No.11021
10950번 문제에서 출력 형식만 바꾸면 된다.

Bash

Bash
1
2
3
4
5
read n
for ((i=0; i<n; i++)); do
	read a b
	echo Case \#$i: $((a + b))
done

C

C
1
2
3
4
5
6
7
8
9
10
11
#include <stdio.h>

int main(void) {
	int n, a, b;
	scanf("%d", &n);
	for (int i=0; i<n; i++) {
		scanf("%d %d", &a, &b);
		printf("Case #%d: %d\n", i+1, a+b);
	}
	return 0;
}

Node.js

JavaScript
1
2
3
4
5
let [n, ...list] = require("fs").readFileSync(0).toString().trim().split("\n");
for (let i in list) {
	let [a, b] = list[i].split(" ").map(Number);
	console.log(`Case #${i*1+1}: ${a+b}`);
}

PHP

PHP
1
2
3
4
5
6
7
<?php
	fscanf(STDIN, "%d", $n);
	for ($i=1; $i<=$n; $i++) {
		fscanf(STDIN, "%d %d", $a, $b);
		echo "Case #$i: ".$a + $b."\n";
	}
?>

Python3

Python
1
2
3
4
n = int(input())
for i in range(n):
    a, b = map(int, input().split())
    print("Case #{}: {}".format(i+1, a+b))

Ruby

Ruby
1
2
3
4
5
n = gets.chomp.to_i
for i in 1..n
  a, b = gets.chomp.split(" ").map {|i| i.to_i}
  puts "Case ##{i}: #{a+b}"
end