C#/수업 과제

C#/수업 과제

[알고리즘] 이진트리 자료구조 정리 및 구현

- 트리 관련 용어 정리- 루트(Root) : 트리의 최상단 노드 간선(Edge) : 두 노드를 잇는 선 브랜치(Branch) : 한 노드에서 갈라져 나온 자식 노드의 수 형제(Sibling) : 부모가 같은 자식노드들 리프(Leaf) : 자식노드가 없는 하단의 노드 높이(Height) : 특정 노드에서 루트 사이의 길이 깊이(Depth) : 루트 노드에서 특정 노드까지의 길이 트리 높이(Tree Height) : 가장 먼 거리에 있는 Leaf 노드와 루트 사이의 길이 트리 깊이(Tree Depth) : 루트 노드에서 가장 먼 리프 노드까지의 길이 레벨(Level) : 루트 노드로부터의 깊이 노드의 차수(Node Degree) : 한 노드의 서브트리의 갯수(자식노드의 수) 트리의 차수(Tree Degre..

C#/수업 과제

[알고리즘] 재귀함수 구현

재귀함수를 이용한 팩토리얼 과 피보나치 수열 구현 using System; namespace RecursivePractice { internal class Program { static void Main(string[] args) { //재귀함수를 이용한 팩토리얼 Console.WriteLine("5*4*3*2*1 = {0}", RecursiveFact(5)); //재귀함수를 이용한 피보나치 수열 Console.WriteLine("0,1,1,2,3 --> {0}", RecursiveFibonacci(5)); } public static int RecursiveFact(int n) { if (n == 1) return 1; else return n * RecursiveFact(n - 1); } public..

C#/수업 과제

[유니티] 토글 버튼 단순 구현

코드 using UnityEngine; using UnityEngine.UI; public class CheckButtonDirector : MonoBehaviour { public Toggle[] toggles; public void Awake() { this.toggles[0].isOn = false; this.toggles[1].isOn = false; } void Start() { for (int i = 0; i { Debug.LogFormat("{0} 의 토글 상태 : {1}", this.toggles[temp].name, x); }); } } } 구현 영상 토..

C#/수업 과제

그래프 탐색 (BFS)

문제 코드 구현 using System; using System.Collections.Generic; namespace BFS { internal class Program { static int N = 7; static int[,] map = new int[N, N]; static string[] cities = { "서울", "대전", "대구", "부산", "광주", "천안", "공주", }; static int[] visited = new int[N]; static void Main(string[] args) { int[,] edges = { {0,1}, {0,2}, {1,3}, {1,4}, {2,5}, {2,6}, }; for (int i = 0; i < N - 1; i++) { int v1 = e..

C#/수업 과제

이분탐색

보호되어 있는 글입니다.

C#/수업 과제

무방향 그래프 2차원 배열로 구현하기

문제 무방향 그래프 (이게 맞게 한건가 모르겠습니다 ㅜㅜㅜ) * 카페 자료 확인하여 분석코드 올렸습니다. 코드 using System; namespace Study16 { internal class App { int[,] map = new int[4, 4]; public App() { for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (i == 0 && j != 0 && j != 3) { map[i, j] = 1; } if (i == 1 && j != 1) { map[i, j] = 1; } if (i == 2 && j != 2 && j != 3) { map[i, j] = 1; } if (i == 3 && j == 1) { map[i, j] =..

C#/수업 과제

C# 인벤토리 만들기

문제 구현 App Class using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace study01 { internal class App { public App() { Inventory inventory = new Inventory(5); inventory.AddItem(new Weapon("장검")); inventory.PrintItem(); inventory.DeleteItem("장검"); inventory.PrintItem(); inventory.AddItem(new Weapon("장검")); inventory.PlusCapacity..

C#/수업 과제

Jason 직렬화 역직렬화 과제

단검 직렬화 (객체를 문자열로) App Class using System; using System.Collections.Generic; using System.IO; using System.Linq; using Newtonsoft.Json; namespace Study11 { class App { //생성자 public App() { //객체를 만들고 직렬화 해서 JSON형식 (문자열) 파일로 저장 Item item = new Item("단검,",5); //직렬화 : 아이템 객체를 넣어 주면 json문자열을 반환 string json = JsonConvert.SerializeObject(item); Console.WriteLine(json); //저장 File.WriteAllText("dagger.jso..

C#/수업 과제

List<T> 와 프로퍼티, 상속을 이용한 인벤토리 과제

App 클래스 using System; using System.Collections; using System.Collections.Generic; namespace Study09 { class App { public App() { Inventory inven = new Inventory(5); inven.AddItem(new Weapon("장검")); inven.AddItem(new Weapon("장검")); inven.AddItem(new Weapon("단검")); inven.AddItem(new Weapon("창")); inven.AddItem(new Weapon("단검")); Console.WriteLine(inven.Count); inven.PrintAllItems(); //장검 x 2 //단검 ..

C#/수업 과제

인벤토리 만들기 (클래스 배열 이용)

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Study08 { class Inventory { private int capacity; //최대 용량 private Item[] items; //아이템들을 관리 배열 int index; //생성자 public Inventory(int capacity) { this.capacity = capacity; //배열 초기화 this.items = new Item[this.capacity]; } public void AddItem(Item item) { for (int i = 0; i < ..

Bueong_E
'C#/수업 과제' 카테고리의 글 목록