A + B - 5 (10952)
Created:
입력한 값이 0 0
이면 반복문을 빠져나온다.
Bash
Bash 1
2
3
4
5
6
7
while :; do
read a b
if [ "$a$b" == "00" ]; then
break
fi
echo $((a + b))
done
while :
== while true
== 무한루프
C
C 1
2
3
4
5
6
7
8
9
10
11
#include <stdio.h>
int main(void) {
int a, b;
while (1) {
scanf("%d %d", &a, &b);
if (a == 0 && b == 0) { break; }
printf("%d\n", a+b);
}
return 0;
}
Node.js
JavaScript 1
2
3
4
5
let list = require("fs").readFileSync(0).toString().trim().split("\n");
for (let l of list.slice(0,-1)) {
let [a, b] = l.split(" ").map(Number);
console.log(a+b);
}
PHP
PHP 1
2
3
4
5
6
7
<?php
while (1) {
fscanf(STDIN, "%d %d", $a, $b);
if ($a == 0 && $b == 0) { break; }
echo $a + $b."\n";
}
?>
Python3
Python 1
2
3
4
while 1:
a, b = map(int, input().split())
if a==0 and b==0: break
print(a+b)
Ruby
Ruby 1
2
3
4
5
while 1
a, b = gets.chomp.split().map {|i| i.to_i}
break if a==0 and b==0
puts a+b
end