Coding Test/BaekJoon
[BaekJoon Java] A+B -8(11022)
momong'-'
2020. 5. 14. 22:30
https://www.acmicpc.net/problem/11022
11022번: A+B - 8
각 테스트 케이스마다 "Case #x: A + B = C" 형식으로 출력한다. x는 테스트 케이스 번호이고 1부터 시작하며, C는 A+B이다.
www.acmicpc.net
- 문제
두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.
- 예제 입출력
- 풀이
import java.util.Scanner;
/**
* 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.
* @author imj10
*
*/
public class ASumB8_11022 {
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 + %d = %d", i+1, a, b, a+b));
}
}
}
- 결과
- 추가설명