C#

C#/수업 내용

매서드 사용법

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study02 { class Program { //매서드 정의시엔 영문으로 동사를 먼저(기능), 대문자로 시작함 static void AttackWolf() { Console.WriteLine("늑대를 공격합니다."); } //Main 매서드 static void Main(string[] args) { SayHello(); } //1.어떤 기능을 할지 머리속에 정한다. //2.그 기능의 의미를 가지고 매서드를 정의한다 //3.class 내부에 void 매서드명(){} //4.머릿속에..

C#/문제 해결

고블릭 죽이기 (계속 체력이 -로 가는 문제)

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study02 { class Program { static void Main(string[] args) { //영웅이름 홍길동 //공격력 2 //체력 10/10 //몬스터 이름 고블린 //공격력 3 //체력 10/10 //홍길동이 고블린을 공격 헀습니다. //고블린이 피해 (-2)를 받았습니다. //고블린의 체력은 8/5 입니다. //홍길동이 고블린을 공격 헀습니다. //고블린이 피해 (-2)를 받았습니다. //고블린의 체력은 6/5 입니다. string hero; string en..

C#/수업 내용

별찍기 2 (for문)

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study02 { class Program { static void Main(string[] args) { for (int i = 0; i < 5; i++) { for (int h = 0; h < 5 - (i + 1); h++) { Console.Write(" "); } for (int j = 0; j

C#/수업 내용

별찍기 (for문)

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study02 { class Program { static void Main(string[] args) { for (int i = 0; i < 8; i++) { for (int j = 0; j < i + 1; j++) { Console.Write("*"); } Console.WriteLine(); } } } }

C#/수업 내용

구구단 자동으로 9단 까지 (for 문)

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study02 { class Program { static void Main(string[] args) { int fsum; int ssum; for (int i = 0; i 1) { Console.WriteLine(); for (int j = 0; j < 9; j++) { fsum = i + 1; ssum = j + 1; Console.WriteLine("{0} X {1} = {2}", fsum, ssum, fsu..

C#/수업 내용

모든 숫자 더하기 (for문)

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study02 { class Program { enum FruitType { Apple, banana } static void Main(string[] args) { Console.WriteLine("더할 숫자를 정해주세요."); int input2 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("{0} 선택하셨습니다.", input2); int sum = 0; for (int i = 0; i < input2; i++) { su..

C#/수업 내용

줄넘기 횟수 (for문)

Console.WriteLine("줄넘기를 몇회 하시겠습니까?."); int input1 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("{0} 선택하셨습니다.", input1); //Console.WriteLine("1부터 n까지 더할 두번째 숫자를 입력해주세요."); //int input2 = Convert.ToInt32(Console.ReadLine()); //Console.WriteLine("{0} 선택하셨습니다.", input2); for (int i = 0; i < input1; i++) { Console.WriteLine("줄넘기를 {0}회 했습니다.", i + 1); } Console.WriteLine("줄넘기를 총 {0}회 했습니다"..

C#/수업 내용

구구단 프로그램 (for문 사용)

string number; int num; number = Console.ReadLine(); int numbermain = Convert.ToInt32(number); Console.WriteLine("{0}단 선택하셨습니다.", number); int result; for (int i = 0; i < 9; i++) { num = i + 1; result = numbermain * num; Console.WriteLine("{0} x {1} = {2}", numbermain, num, result); } 연산자 * 는 곱하기

C#/수업 과제

고블린 원펀 코드 (if 문 사용)

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study02 { class Program { enum ItemType { SWORD, DAGGER } static void Main(string[] args) { string hero = "Alan"; string enemy; string heroPow; int enemyMaxhp; int enemyhp; int hheroPow; enemy = "고블린"; heroPow = Console.ReadLine(); enemyMaxhp = 15; enemyhp = enemyMaxhp; h..

C#/수업 내용

변환 예시

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study02 { class Program { enum ItemType { SWORD, DAGGER } static void Main(string[] args) { //형식 변환 //문자열(숫자형) -> 정수 string strNum = "12"; int num = Convert.ToInt32(strNum); //정수 -> 문자열 int num2 = 300; string strNum2 = num2.ToString(); //정수 -> 실수 int num3 = 123; float fNu..

Bueong_E
'C#' 카테고리의 글 목록 (8 Page)