두 정수 A, B를 비교하는 프로그램을 작성하는 문제로 if문을 이용하여 푸는 문제이다.
A,B의 제한때문에 if문을 더 작성하였는데 해당 if문은 작성하지 않아도 채점에는 무방할 것 같다.
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
33
34
35
36
37
38
39
40
|
using System;
public class MainClass
{
public static void Main()
{
string value = Console.ReadLine();
string[] result = value.Split(' ');
int a = Convert.ToInt32(result[0]);
int b = Convert.ToInt32(result[1]);
if (CheckValue(a) && CheckValue(b))
{
if (a > b)
{
Console.WriteLine(">");
}
else if (a < b)
{
Console.WriteLine("<");
}
else if (a == b)
{
Console.WriteLine("==");
}
}
}
private static bool CheckValue(int value)
{
if (value >= -10000 && value <= 10000)
{
return true;
}
else
{
return false;
}
}
}
|
cs |
'C#' 카테고리의 다른 글
[백준] 2753번 윤년 C# 풀이 (0) | 2019.09.24 |
---|---|
[백준] 9498번 시험성적 C# 풀이 (0) | 2019.09.21 |
[DataGridView] 마지막 행 없애기 (0) | 2019.04.21 |
[DataGridView] 행 머리글 열 Row Headers 없애기 (0) | 2019.04.15 |
[DataGridView] 두 개의 DataGridView 동시에 스크롤하기 (0) | 2019.04.07 |