백준 11021 : A+B - 7

C# 2020. 11. 30. 22:50

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

첫째 줄에 테스트 케이스의 개수 T가 주어진다.

각 테스트 케이스는 한 줄로 이루어져 있으며, 각 줄에 A와 B가 주어진다. (0 < A, B < 10)
각 테스트 케이스마다 "Case #x: "를 출력한 다음, A+B를 출력한다. 테스트 케이스 번호는 1부터 시작한다.

:: 성공

: 개선점 : 없음

using System;

namespace for01
{
    class Program
    {
        static void Main(string[] args)
        {
            // :: Input size and Parse
            int size = Int32.Parse(Console.ReadLine());

            // :: result Array
            string[] result = new string[size];

            // :: Loop with size
            for(int i = 1; i <= size; i++)
            {
                // :: Input and Parse
                string[] input = Console.ReadLine().Split(' ');
                int a = Int32.Parse(input[0]);
                int b = Int32.Parse(input[1]);

                // :: Save Result
                result[i - 1] = String.Format("Case #{0}: {1}", i, a + b);
            }

            // :: Print with "Wn" for Spped
            Console.WriteLine(string.Join("\n", result));
        }
    }
}

'C#' 카테고리의 다른 글

백준 10871 : X보다 작은 수  (0) 2020.12.04
백준 2439 : 별 찍기 - 2  (0) 2020.12.03
백준 2742 : 기찍 N  (0) 2020.11.29
백준 2741 : N 찍기  (0) 2020.11.28
백준 15552 : 빠른 A+B  (0) 2020.11.27
블로그 이미지

RIsN

,