Coding Test/BaekJoon

[BaekJoon Java] A+B - 7(11021)

momong'-' 2020. 5. 14. 22:29

https://www.acmicpc.net/problem/11021

 

11021번: A+B - 7

각 테스트 케이스마다 "Case #x: "를 출력한 다음, A+B를 출력한다. 테스트 케이스 번호는 1부터 시작한다.

www.acmicpc.net


  • 문제

두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.

  • 예제 입출력

  • 풀이
import java.util.Scanner;

/**
 * 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.
 * @author imj10
 *
 */
public class ASumB7_11021 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int caseCnt = sc.nextInt();
		
		for ( int i=0; i < caseCnt; i++ ) {
			
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			System.out.println(String.format("Case #%d: %d", i+1, a+b));
		}
	}
}

 

  • 결과


  • 추가설명