세 수
C#/Algorithm 2019. 9. 25. 16:17문제
세 정수 A, B, C가 주어진다. 이때, 두 번째로 큰 정수를 출력하는 프로그램을 작성하시오.
입력
첫째 줄에 세 정수 A, B, C가 공백으로 구분되어 주어진다. (1 ≤ A, B, C ≤ 100)
출력
두 번째로 큰 정수를 출력한다.
예제 입력 1
20 30 10
예제 출력 1
20
예제 입력 2
30 30 10
예제 출력 2
30
예제 입력 3
40 40 40
예제 출력 3
40
예제 입력 4
20 10 10
예제 출력 4
10
코드
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _09._24_step2
{
class Program
{
static void Main(string[] args)
{
string input = Console.ReadLine();
int num1 = Convert.ToInt32(array[0]);
int num2 = Convert.ToInt32(array[1]);
int num3 = Convert.ToInt32(array[2]);
if (num1 > num2 && num1 > num3)
{
if (num2 < num3)
{
Console.WriteLine(num3);
}
else if (num2 == num3)
{
Console.WriteLine(num2);
}
else
{
Console.WriteLine(num2);
}
}
else if (num2 >= num1 && num2 >= num3)
{
if (num3 < num1)
{
Console.WriteLine(num1);
}
else if (num3 == num1)
{
Console.WriteLine(num3);
}
else
{
Console.WriteLine(num3);
}
}
else if (num3 >= num1 && num3 >= num2)
{
if (num2 < num1)
{
Console.WriteLine(num1);
}
else if (num2 == num1)
{
Console.WriteLine(num2);
}
else
{
Console.WriteLine(num2);
}
}
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|