본문 바로가기
반응형

코딩테스트 준비211

C# - 두 변수 값 교환 하는 법 1. 변수 설정하기 int A = 10; int B = 20; 2. A변수의 값을 넣어줄 공간 만들어주기 int temp; 3. temp에 A값 할당해주기 temp = A; 4. A변수에 B값 넣기 A = B; 5. temp에 있는 값 B변수에 넣기 B = temp; 6. 최종 코드 int A = 10; int B = 20; int temp; Console.WriteLine($"변수 A의 값은 {A} B의 값은 {B} "); temp = A; A = B; B = temp; Console.WriteLine($"변수 A의 값은 {A} B의 값은 {B} "); 2023. 4. 12.
C# - 배열에서 최댓값 최솟값 1. max, min 값 설정하기 주어진 조건의 최솟값을 max변수의 값으로 설정하고 최댓값을 min변수의 값으로 설정한다. 예를 들어서 입력되는 정수의 값의 범위가 -100 2023. 4. 11.
백준 C# 10810 using System; using System.Collections.Generic; using System.Text; namespace baek2 { class Program { static void Main(string[] args) { string input_NM = Console.ReadLine(); string[] token_NM = input_NM.Split(); int N = int.Parse(token_NM[0]); int M = int.Parse(token_NM[1]); int[] arr = new int[N]; for(int i=0; i < N; i++) { arr[i] = 0; } for (int i = 0; i < M; i++) { string input = Console.ReadL.. 2023. 4. 11.
백준 C# 2562 using System; using System.Collections.Generic; using System.Text; namespace baek2 { class Program { static void Main(string[] args) { int[] arr = new int[9]; int count = 0; int max = 0; for (int i = 0; i max) { max = arr[i]; count = i; } } Console.WriteLine(max); Console.WriteLine(count+1); } } } 2023. 4. 11.
백준 C# 10818 배열에서 최댓값 최솟값 구하는 방법 알아보러 가기 배열에서 최댓값 최솟값 배열에서 최댓값 최솟값 구하기 1. max, min 값 설정하기 주어진 조건의 최솟값을 max변수의 값으로 설정하고 최댓값을 min변수의 값으로 설정한다. 예를 들어서 입력되는 정수의 값의 범위가 -100 code-piggy.tistory.com using System; using System.Collections.Generic; using System.Text; namespace baek2 { class Program { static void Main(string[] args) { string input = Console.ReadLine(); int n = int.Parse(input); string input_list = Con.. 2023. 4. 11.
백준 C# 10871 using System; using System.Collections.Generic; using System.Text; namespace baek2 { class Program { static void Main(string[] args) { string input_n = Console.ReadLine(); string[] token_n = input_n.Split(); int n = int.Parse(token_n[0]); int x = int.Parse(token_n[1]); string input_list = Console.ReadLine(); string[] token = input_list.Split(); int[] arr = new int[n]; for(int i=0; i 2023. 4. 11.
반응형