๋ฐ์ํ
import java.util.Scanner;
public class Main {
// 10951 A+B - 4
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNextInt()) {
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(a + b);
}
}
}
์๋ while(true)๋ก ํด์ ๋ต์ ์ ์ถํ๋๋ ๋ฐํ์์๋ฌ๊ฐ ๋๋๊ตฐ์.
Scanner class์ hasNextInt()ํจ์๋ฅผ ์ฌ์ฉํ๋ฉด ๋๋ ๊ฑฐ์์ด์ ๊ณ ์ณ ๋๋๋ ๋ง์ท์ต๋๋ค.
๋ฐ์ํ
'๐ธ Algorithm > ๐ธ ๋ฐฑ์ค BaekJoon' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค][java][10871][X๋ณด๋ค ์์ ์] (0) | 2023.10.15 |
---|---|
[๋ฐฑ์ค][java][10807][๊ฐ์ ์ธ๊ธฐ] (0) | 2023.10.15 |
[๋ฐฑ์ค][java][10952][A+B - 5] (0) | 2023.10.09 |
[๋ฐฑ์ค][java][2439][๋ณ ์ฐ๊ธฐ - 2] (0) | 2023.10.09 |
[๋ฐฑ์ค][java][2438][๋ณ ์ฐ๊ธฐ - 1] (0) | 2023.10.09 |