(C#) 4. 코드의 흐름 제어 (if-else)
if와 else
if-else
- 최초 작성일: 2021년 3월 21일(월)
##
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
using System;
namespace if_else
{
class Program
{
static void Main(string[] args)
{
int choice = 0; // 0:가위, 1:바위, 2:보, 3:치트키
if (choice == 0)
{
Console.WriteLine("가위입니다.");
}
else if (choice == 1)
{
Console.WriteLine("바위입니다.");
}
else if (choice == 2)
{
Console.WriteLine("보입니다.");
}
else
{
Console.WriteLine("치트키입니다.");
}
}
}
}
이 기사는 저작권자의 CC BY 4.0 라이센스를 따릅니다.