백준 11021

Hyerin·2021년 12월 7일
0
post-thumbnail

문제

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

C# 풀이

using System;
using System.IO;

namespace baekjoon
{
    class Program
    {
        static void Main(string[] args)
        {
            // 표준 입출력 스크림 reader,writer만들기
            // 테스트케이스 개수 입력받기, int로 바꾸기
            // 테스트케이스 개수만큼 반복해서 정수 2개 입력받기, 분리하기, int로 바꾸기 
            // 두 정수를 더한 값을 버퍼에 저장, 버퍼 한 번에 비우기

            StreamReader sr = new StreamReader(Console.OpenStandardInput());
            StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());

            string TestCase = sr.ReadLine();
            int nTestCase = int.Parse(TestCase);

            for (int i = 1; i <= nTestCase; i++)
            {
                string strInput = sr.ReadLine();
                string[] strNum = strInput.Split(' ');
                int nNumA = int.Parse(strNum[0]);
                int nNumB = int.Parse(strNum[1]);
                sw.WriteLine("Case #" + i + ": " + (nNumA+ nNumB));
            }
            sw.Flush();
            sr.Close();
            sw.Close();
        }
    }
}

0개의 댓글