본문 바로가기
반응형

전체 글213

텍스트 알피지!! using System.Security.Cryptography.X509Certificates; using System.Transactions; using static CSharp.Program; namespace CSharp { class Program { public enum ClassType { NONE,기사,궁수,마법사 } struct Player { public int hp; public int attack; public int exp; } enum MonsterType { NONE, Slime, Orc, Skeleton } struct Monster { public int hp; public int attack; } static ClassType ChoiceJob() { ClassType cla.. 2023. 7. 4.
디버깅 기초 단축키 설명 F9 브레이크 포인트 지정 F5 실행 F11 한 단계씩 코드 실행 F10 프로시저 단위 실행 중단점 우클릭 + Alt + F9, C 중단점 조건 조사식에서 값을 변경할수도 있다. 프레이크 포인트 말고도 디버그 로그로도 할수도 있다. 2023. 7. 4.
팩토리얼 using System.Transactions; namespace CSharp { class Program { static int Factorial(int n) { int result = 1; for (int i = 0; i 2023. 7. 2.
별찍기 using System.Transactions; namespace CSharp { class Program { static void Main(string[] args) { string stars = " "; for (int i = 0; i 2023. 7. 2.
구구단! using System.Transactions; namespace CSharp { class Program { static void Multiplication(int a, int b,ref int result) { result = a * b; Console.WriteLine($"{a} * {b} = {result}"); } static void Main(string[] args) { int result = 0; for (int a = 1; a 2023. 7. 2.
오버로딩 using System.Transactions; namespace CSharp { class Program { static int Add(int a, int b) { return a + b; } static int Add(int a, int b,int c) { return a + b + c; } static float Add(float a, float b) { return a + b; } static void Main(string[] args) { int ret = Program.Add(2, 3); int ret3 = Program.Add(2, 3, 4); float ret1 = Program.Add(2.0f, 3.0f); Console.WriteLine(ret); Console.WriteLine(ret.. 2023. 7. 2.
ref, out ref using System.Transactions; namespace CSharp { class Program { static void Swap(ref int a, ref int b) { int tenmp = a; a = b; b = tenmp; } static void AddOne(ref int number) { number = number + 1; } static int AddOne2(int number) { return number + 1; } static void Main(string[] args) { //복사(짭퉁) 참조(진퉁) int num1 = 1; int num2 = 2; Program.Swap(ref num1, ref num2); Console.WriteLine($"{num1} {nu.. 2023. 7. 2.
break, continue break문 namespace CSharp { class Program { static void Main(string[] args) { int num = 97;// 1, 97로만 나뉘는 숫자 bool isPrime = true; for (int i = 2; i 2023. 7. 2.
For문 namespace CSharp { class Program { static void Main(string[] args) { int count = 5; for (int i = 0; i 0) { Console.WriteLine("Hello World"); count--; } } } } 2023. 7. 2.
While(반복문) While namespace CSharp { class Program { static void Main(string[] args) { int count = 5; while (count > 0) { Console.WriteLine("Hello World"); count--; } } } } DoWhile namespace CSharp { class Program { static void Main(string[] args) { string answer; //거울아 거울아 ~ do { Console.WriteLine("나는 잘생겼나욧?(y/n) : "); answer = Console.ReadLine(); } while (answer != "y"); } } } 2023. 7. 2.
상수와 열거형 상수 (const) ex1) namespace CSharp { class Program { static void Main(string[] args) { const int ROCK = 1; const int PAPER = 2; const int SCISSORS = 0; Random rand = new Random(); int aiChoice = rand.Next(0, 3);//0~2 사이의 랜덤 값 int choice = Convert.ToInt32(Console.ReadLine()); switch (choice) { case SCISSORS: Console.WriteLine("당신의 선택은 가위입니다."); break; case ROCK: Console.WriteLine("당신의 선택은 바위입니다.");.. 2023. 7. 2.
가위 바위 보 게임!! 내가 짠 코드 namespace CSharp { class Program { static void Main(string[] args) { Random rand = new Random(); int aiChoice = rand.Next(0, 3);//0~2 사이의 랜덤 값 bool isWin; int choice = Convert.ToInt32(Console.ReadLine()); switch(choice) { case 0: Console.WriteLine("당신의 선택은 가위입니다."); break; case 1: Console.WriteLine("당신의 선택은 바위입니다."); break; case 2: Console.WriteLine("당신의 선택은 보입니다."); break; } switch (aiC.. 2023. 7. 2.
반응형