5일차 세 개의 정수를 입력받아 두번째로 큰 수 출력

Console Programming/C# Console 2019. 9. 24. 13:11
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Syntax11
{
    class Program
    {
        static void Main(string[] args)
        {
            int num1, num2, num3;
            Console.Write("입력1 : ");
            num1 = Int32.Parse(Console.ReadLine());
            Console.Write("입력2 : ");
            num2 = Int32.Parse(Console.ReadLine());
            Console.Write("입력3 : ");
            num3 = Int32.Parse(Console.ReadLine());
 
            int firstLarge = 0, secondLarge = 0;
            if (num1 < 0 || num1 > 100 || num2 < 0 || num2 > 100 || num3 < 0 || num3 > 100)
            {
                Console.WriteLine("범위가 벗어났습니다.(0~100)");
            }
            else
            {
 
                if (num1 >= num2 && num1 >= num3)
                {
                    firstLarge = num1;
                    if (num1 == num2 || num1 == num3)
                    {
                        secondLarge = num1;
                    }
                    else if (num2 > num3)
                    {
                        secondLarge = num2;
                    }
                    else
                    {
                        secondLarge = num3;
                    }
                }
                else if (num2 >= num1 && num2 >= num3)
                {
                    firstLarge = num2;
                    if (num2 == num1 || num2 == num3)
                    {
                        secondLarge = num2;
                    }
                    else if (num1 > num3)
                    {
                        secondLarge = num1;
                    }
                    else
                    {
                        secondLarge = num3;
                    }
                }
                else if (num3 >= num1 && num3 >= num2)
                {
                    firstLarge = num3;
                    if (num3 == num1 || num3 == num2)
                    {
                        secondLarge = num3;
                    }
                    else if (num1 > num2)
                    {
                        secondLarge = num1;
                    }
                    else
                    {
                        secondLarge = num2;
                    }
                }
                else if (num1 == num2 && num1 == num3)
                {
                    secondLarge = num1;
                }
                Console.WriteLine($"두번째 큰 수는 {secondLarge}");
            }
        
    }
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

 

 

: