728x90
๋ฐ˜์‘ํ˜•

๋ฌธ์ œ

๋‘ ์ •์ˆ˜ A์™€ B๋ฅผ ์ž…๋ ฅ๋ฐ›์€ ๋‹ค์Œ, A+B๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.

์ž…๋ ฅ

์ฒซ์งธ ์ค„์— ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค์˜ ๊ฐœ์ˆ˜ T๊ฐ€ ์ฃผ์–ด์ง„๋‹ค.

๊ฐ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋Š” ํ•œ ์ค„๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ์œผ๋ฉฐ, ๊ฐ ์ค„์— A์™€ B๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. (0 < A, B < 10)

์ถœ๋ ฅ

๊ฐ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋งˆ๋‹ค "Case #x: A + B = C" ํ˜•์‹์œผ๋กœ ์ถœ๋ ฅํ•œ๋‹ค. x๋Š” ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค ๋ฒˆํ˜ธ์ด๊ณ  1๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜๋ฉฐ, C๋Š” A+B์ด๋‹ค.

import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		
		for (int i =1; i<=T; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			System.out.println("Case #" + i + ": " + a + " + " + b + " = " + (a+b));
		}
		sc.close();
	}
}

๊ณ„์† ๋น„์Šทํ•œ ๋ถ€๋ถ„์ด๋ผ ์ด์ œ ๋ฐ˜๋ณต๋ฌธ์€ ๋‘๋ฌธ์ œ์”ฉ ํ’€๊ฒŒ์š”...

 

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.IOException;
import java.util.StringTokenizer;

public class Main {
	public static void main (String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		StringTokenizer st;
		int T = Integer.parseInt(br.readLine());
		
		for (int i=1; i<=T; i++) {
			
			st = new StringTokenizer(br.readLine());
			
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			
			bw.write("Case #"+ i + ": " + a + " + " + b + " = " + (a+b) + "\n");
		}
		bw.close();
	}
}

์นœ๊ตฌ๊ฐ€ import ๋ถ€๋ถ„ import java.io*๋กœ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ๋‹ค ๊ทธ๋žฌ๋Š”๋ฐ ์ €๋Š” ์™œ ์—๋Ÿฌ ๋œฐ๊นŒ์š”... ใ…‡ใ…ˆ๋‹˜.....

๊ทธ๋ž˜์„œ ๊ทธ๋ƒฅ ์›๋ž˜ ํ•˜๋˜๋Œ€๋กœ ๋‹ค ์ ์–ด๋ณด์•˜์Šต๋‹ˆ๋‹ค...

์–ด์ œ ๋ฌธ์ œ๋ž‘ ๋‹ค๋ฅธ๊ฑฐ๋Š” ๋ฐ‘์— write๋ถ€๋ถ„ ์ •๋„๋ผ ๊ทธ๋‹ฅ ํ•œ๊ฒŒ ์—†๋„ค์šฉ

์‚ฌ์‹ค ์–ด์ œ(13์ผ)์— ํ–ˆ๋Š”๋ฐ ๊ธฐ์ ˆํ•ด๋ฒ„๋ ค์„œ ์˜ค๋Š˜ ์•„์นจ์— ์ ์–ด๋ด…๋‹ˆ๋‹ค ใ…œใ…œ 

์˜ค๋Š˜์€ ๋ณ„์ฐ๊ธฐ๋กœ ๋งŒ๋‚˜์š” โœจโœจ

728x90
๋ฐ˜์‘ํ˜•

+ Recent posts