C#
백준 11022 : A+B - 8
RIsN
2020. 12. 27. 22:36
두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.
첫째 줄에 테스트 케이스의 개수 T가 주어진다.
각 테스트 케이스는 한 줄로 이루어져 있으며, 각 줄에 A와 B가 주어진다. (0 < A, B < 10)
각 테스트 케이스마다 "Case #x: A + B = C" 형식으로 출력한다. x는 테스트 케이스 번호이고 1부터 시작하며, C는 A+B이다.
:: 성공
: 개선점 : 없음
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} + {2} = {3}", i, a, b, a + b);
}
// :: Print with "Wn" for Spped
Console.WriteLine(string.Join("\n", result));
}
}
}