C#/C# 연습 26

Array : Random Number (난수), Coin (동전 개수)

문제 8 실행결과와 같이 되도록 프로그램을 작성하시오. int[] code {-9, -55, 73, 116, 101, 205, 1000}초기화 조건 : arr배열의 값들은 code배열에 있는 값으로만 존재함 아울러, 난수를 발생시켜 대입토록 한다. 실행결과 출력되는 값은 code배열에 있는 값으로만 구성됨 arr배열 값 출력 [-55, 1000, 1000, -9, 73, -9, 116, -55, 1000, 1000] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Array_08 { internal class Program { s..

C#/C# 연습 2022.11.30

Array : Sort, Reverse (정렬)

문제 7 실행결과와 같이 되도록 프로그램을 작성하시오. 조건 : 배열의 i번째 요소와 임의의 요소에 저장된 값을 서로 바꿔서 값을 섞은 후 내림차순으로 정렬 후 0~5번 인덱스의 값만 출력하도록 한다. 실행결과 0~19번 방까지의 값 출력 ball[0]=1 ball [1]=2 ball [2]=3 ball [3]=4 ... ball배열의 앞에서부터 6개만 출력(값을 섞은 후, 내림차순 소팅한 결과) ball [0]=20 ball [1]=19 ball [2]=18 ball [3]=17 ball [4]=16 ball [5]=15 using System; using System.Collections.Generic; using System.Linq; using System.Security.Cryptography;..

C#/C# 연습 2022.11.30

Array : Combine, Random (섞기, 랜덤)

문제 5 아래의 실행결과가 나오도록 프로그램을 작성하시오. 타입 변수명 설명 int[] numArr 10개의방 생성 조건 : 값을 섞는다 실행결과 원래의 배열 값들을 출력 0,1,2,3,4,5,6,7,8,9 값을 임의로 섞은후 출력 0,4,9,3,5,6,2,8,7,1 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace pr_array_02 { internal class Program { static void Main(string[] args) { Random rand = new Random(); int[] arr = new int[1..

C#/C# 연습 2022.11.29

Array : Input, MaxMin (입력, 최대값 최소값)

문제3 배열의 요소 수와 각 요소의 값을 입력하면 실행결과와 같이 각 요소의 값을 표시하는 프로그램을 작성하시오. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace pr_array_02 { internal class Program { static void Main(string[] args) { int input = int.Parse(Console.ReadLine()); int[] arr = new int[input]; for (int i = 0; i < arr.Length; i++) { arr[i] = int.Parse(Consol..

C#/C# 연습 2022.11.29

Array : Length input, Random (배열수 입력, 난수)

문제 1 배열수를 입력받아 초기화하여 값을 출력하시오 실행결과 배열수 입력:10 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace pr_array_01 { internal class Program { static void Main(string[] args) { Console.WriteLine("배열수를 입력"); int input = int.Parse(Console.ReadLine()); int [] array = new int[input]; for (int i = 0; i < array.Length; i++) { Console.W..

C#/C# 연습 2022.11.28