두 수 비교하기

C#/Algorithm 2019. 9. 25. 16:10

문제

두 정수 A와 B가 주어졌을 때, A와 B를 비교하는 프로그램을 작성하시오.

입력

첫째 줄에 A와 B가 주어진다. A와 B는 공백 한 칸으로 구분되어져 있다.

출력

첫째 줄에 다음 세 가지 중 하나를 출력한다.

  • A가 B보다 큰 경우에는 '>'를 출력한다.
  • A가 B보다 작은 경우에는 '<'를 출력한다.
  • A와 B가 같은 경우에는 '=='를 출력한다.

제한

  • -10,000 ≤ A, B ≤ 10,000

예제 입력 1

1 2

예제 출력 1

<

예제 입력 2

10 2

예제 출력 2

>

예제 입력 3

5 5

예제 출력 3

==

코드:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace _1330
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] array = input.Split(' ');
            int a = Convert.ToInt32(array[0]);
            int b = Convert.ToInt32(array[1]);
            if (a> b)
            {
                Console.WriteLine(">");
            }
            else if (a<b)
            {
                Console.WriteLine("<");
            }
            else
            {
                Console.WriteLine("==");
            }
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 

참조:https://www.acmicpc.net/problem/1330

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

설탕 배달  (0) 2019.09.25
세 수  (0) 2019.09.25
알람시계  (0) 2019.09.25
윤년  (0) 2019.09.25
시험 성적  (0) 2019.09.25
: