์ ๋ชฉ์ ๋งํฌ๋ฅผ ์ ๋ ฅํ๋ฉด ํด๋น ๋ฌธ์ ๋ก ์ด๋ํฉ๋๋ค.
1 | 10952 | A+B - 5 | Java |
0 0์ด ๋ค์ด์ฌ ๋๊น์ง A+B๋ฅผ ์ถ๋ ฅํ๋ ๋ฌธ์
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException{
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bfw = new BufferedWriter(new OutputStreamWriter(System.out));
int A =1;
int B =1;
while(true) {
StringTokenizer st = new StringTokenizer(bfr.readLine());
A = Integer.parseInt(st.nextToken());
B = Integer.parseInt(st.nextToken());
if(A==0 && B==0) break;
bfw.write(Integer.toString(A+B));
bfw.newLine();
bfw.flush();
}
bfw.close();
bfr.close();
}
}
2 | 10951 | A+B - 4 | Java |
์ ๋ ฅ์ด ๋๋ ๋๊น์ง A+B๋ฅผ ์ถ๋ ฅํ๋ ๋ฌธ์ . EOF์ ๋ํด ์์ ๋ณด์ธ์.
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
while(scan.hasNext()) {
int a = scan.nextInt();
int b = scan.nextInt();
System.out.println(a+b);
}
}
}
3 | 1110 | ๋ํ๊ธฐ ์ฌ์ดํด | Java |
์๋ ์๋ก ๋์์ฌ ๋๊น์ง ์ฐ์ฐ์ ๋ฐ๋ณตํ๋ ๋ฌธ์
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int old_new = n;
int count = 0;
while(true) {
int a = n/10;//์ฃผ์ด์ง ๊ฐ์ 10์์๋ฆฌ
int b = n%10;//์ฃผ์ด์ง ๊ฐ์ 1์์๋ฆฌ
int c = a+b; //์ฒ์ ์ฃผ์ด์ง ๊ฐ์ ํฉ
int x = c%10;//์ฒ์ ์ฃผ์ด์ง ๊ฐ์ 1์์๋ฆฌ
n = b*10 + x; //์๋ก ๋ง๋ค์ด์ง ๊ฐ.
count++;
if(old_new == n) break;
}
System.out.println(count);
scan.close();
}
}
728x90
๋ฐ์ํ