상세 컨텐츠

본문 제목

백준#10951 - A+B - 4

C#/알고리즘

by McRobbin 2020. 4. 8. 10:01

본문

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

 

10951번: A+B - 4

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

www.acmicpc.net

while문으로 분류된 문제입니다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace _10951
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (input == null)
                    break;
                Console.WriteLine(int.Parse(input.Split(' ')[0]) + int.Parse(input.Split(' ')[1]));
            }
        }
    }
}
 
 
 

 

10952문제와 유사하지만 끝나는 지점이 따로 있지 않습니다. 무한 반복으로 입력을 받으며

입력받은 string값이 null일 때 (아무것도 들어오지 않았을 때) 종료되도록 했습니다.

'C# > 알고리즘' 카테고리의 다른 글

백준#1110 - 더하기 사이클  (0) 2020.04.08
백준#5585 - 거스름돈  (0) 2020.04.08
백준#10952-A+B - 5  (0) 2020.04.08
백준#1931-회의실배정  (0) 2020.04.07
백준#11047-동전 0  (0) 2020.04.07

관련글 더보기