Machineboy空
백준 10951: A+B - 4 (while문 활용) 입력값 마지막 줄까지 읽는 법 본문
using System;
using System.Text;
namespace CodingTestForBaekJoon
{
class Program
{
static void Main(string[] args)
{
while (true)
{
string input = Console.ReadLine();
if (input == null)
{
break;
}
string[] cases = input.Split();
int a = int.Parse(cases[0]);
int b = int.Parse(cases[1]);
Console.WriteLine(a+b);
}
}
}
}
오답이유) 테스트 케이스가 몇 줄인지를 알아서 그만큼 반복을 한 뒤 탈출하는 코드를 잘못짰다.
'Computer > Coding Test' 카테고리의 다른 글
프로그래머스 - 옹알이(1) (0) | 2023.09.19 |
---|---|
백준 1546: 평균 (자료형 구분) (0) | 2023.09.08 |
백준 2562: 최댓값 / 알고리즘: 최단 거리 갱신 (0) | 2023.09.06 |
백준 15552: 빠른 A+B (입출력 시간 단축) (0) | 2023.09.06 |
백준 10171,10172: C# 특수문자 출력( \ ,",)) (1) | 2023.09.04 |