본문 바로가기

분류 전체보기79

List<T> 356 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 using System; using System.Collections.Generic; namespace ee { class MainApp { static void Main(string[] args) { List list = new List(); for (int i = 0; i 2022. 7. 22.
2차원 배열 314 데이터형식[,] 배열이름 = new 데이터형식[2차원길이, 1차원길이]; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 using System; namespace ee { class MainApp { static void Main(string[] args) { int[,] arr = new int[2, 3] { { 1, 2, 3 }, { 4, 5, 6 } }; for (int i = 0; i 2022. 7. 22.
배열을 초기화하는 세 가지 방법 1. 배열의 원소 개수를 명시하고, 괄호{}로 둘러싸인 블록을 붙인 뒤, 블록 사이에 배열의 각 원소에 입력될 데이터를 입력하면 됩니다. 2. 배열의 용량을 생략 3. new 연산자, 형식과 괄호 [], 배열의 용량 모두를 생략한 체 코드 블록 사이에 배열의 각 원소에 할당할 데이터를 넣어주면 됩니다. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 using System; namespace ee { class MainApp { static void Main(string[] args) { string[] array1 = new string[3] { "안녕", "hello", "halo" }; Console.Writ.. 2022. 7. 22.
foreach 문을 이용하여 점수를 출력하고 평균을 계산해서 출력하는 프로그램 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 using System; namespace ee { class MainApp { static void Main(string[] args) { int[] scores = new int[5]; scores[0] = 80; scores[1] = 77; scores[2] = 88; scores[3] = 55; scores[4] = 76; foreach (int score in scores) Console.WriteLine(score); int sum = 0; foreach (int score in scores) sum += score; int average = sum / scores.Length.. 2022. 7. 22.