10950번 문제에서 출력 형식만 바꾸면 된다.
Bash
bash
read n
for ((i=0; i<n; i++)); do
read a b
echo Case \#$i: $((a + b))
done
1
2
3
4
5
2
3
4
5
C
c
#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;
}
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
Node.js
javascript
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}`);
}
1
2
3
4
5
2
3
4
5
PHP
php
<?php
fscanf(STDIN, "%d", $n);
for ($i=1; $i<=$n; $i++) {
fscanf(STDIN, "%d %d", $a, $b);
echo "Case #$i: ".$a + $b."\n";
}
?>
1
2
3
4
5
6
7
2
3
4
5
6
7
Python3
python
n = int(input())
for i in range(n):
a, b = map(int, input().split())
print("Case #{}: {}".format(i+1, a+b))
1
2
3
4
2
3
4
Ruby
ruby
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
1
2
3
4
5
2
3
4
5
Comments
Not supported comment edit and upvote
You can do it on this page if you want.