inblog logo
|
muaga's Hub
    BACKJOON-Java

    [백준/Java] 11021번 A+B - 7 (반복문)

    [백준/Java] 11021번 A+B - 7 (반복문)
    muaga's avatar
    muaga
    Jun 13, 2024
    [백준/Java] 11021번 A+B - 7 (반복문)
    Contents
    문제입력출력답
     

    문제


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

    입력


    첫째 줄에 테스트 케이스의 개수 T가 주어진다.
    각 테스트 케이스는 한 줄로 이루어져 있으며, 각 줄에 A와 B가 주어진다. (0 < A, B < 10)

    출력


    각 테스트 케이스마다 "Case #x: "를 출력한 다음, A+B를 출력한다. 테스트 케이스 번호는 1부터 시작한다.
    입력
    출력
    5 → T 1 1 2 3 3 4 9 8 5 2
    Case #1: 2 Case #2: 5 Case #3: 7 Case #4: 17 Case #5: 7
     

    답


    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 n = 1; n <= t; n++){ int a = sc.nextInt(); int b = sc.nextInt(); System.out.println("Case #"+ n + ": " + (a+b)); } sc.close(); } }
    Share article
    Contents
    문제입력출력답

    muaga's Hub

    RSS·Powered by Inblog