C#/수업 내용

C#/수업 내용

무기 습득 횟수 (메서드 인자 사용)

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study01 { class App { public App() { Console.WriteLine("App"); GetItems("장검",2); GetItems("단검",1); GetItems("창",3); } void GetItems(string weapon, int num ) { for(int i =0; i < num; i++) { Console.WriteLine("{0}을 획득하였습니다.",weapon); } } } }

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#/수업 내용

별찍기 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#/수업 내용

변환 예시

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..

C#/수업 내용

바나나 if문 에제

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) { string fruitName; //변수정의 fruitName = "banana"; //변수값 할당 int fruitfPrice = 40; if(fruitName == "바나나" || fruitName == "버네너") { Console.WriteLine("Banana"); } else if(fruitName == "바나나" && fruitfPrice

Bueong_E
'C#/수업 내용' 카테고리의 글 목록 (5 Page)