●
06. for
using System; namespace Csharp { class Program { static void Main(string[] args) { for (int i = 0; i < 5; i++) { Console.WriteLine("Hello World"); } } } }
05. while
첫 번째 - While문 using System; using System.Collections.Generic; namespace Csharp { class Program { static void Main(string[] args) { int a = 1; while(true) { a++; } Console.WriteLine(a); } } } using System; namespace Csharp { class Program { static void Main(string[] args) { //while 반복문 int count = 0; while (count < 5) { Console.WriteLine("Hello World"); count++; } } } } 두 번째 - do while문 using Sys..
04. 상수와 열거형(하드코딩 교정)
using System; namespace Csharp { class Program { static void Main(string[] args) { //0:가위 1:바위 2:보 Random rand = new Random(); //ai가 고르는 0 ~ 2사이의 랜덤 값 int aiChoice = rand.Next(0, 3); int choice = Convert.ToInt32(Console.ReadLine()); switch (choice) { case 0: Console.WriteLine("당신의 선택은 가위입니다"); break; case 1: Console.WriteLine("당신의 선택은 바위입니다."); break; case 2: Console.WriteLine("당신의 선택은 보입니다."); ..
03. 가위-바위-보 게임
첫 번째 방법 using System; namespace Csharp { class Program { static void Main(string[] args) { //0:가위 1:바위 2:보 Random rand = new Random(); //ai가 고르는 0 ~ 2사이의 랜덤 값 int aiChoice = rand.Next(0, 3); int choice = Convert.ToInt32(Console.ReadLine()); switch(choice) { case 0: Console.WriteLine("당신의 선택은 가위입니다"); break; case 1: Console.WriteLine("당신의 선택은 바위입니다."); break; case 2: Console.WriteLine("당신의 선택은 보입..