본문 바로가기
반응형

코딩테스트 준비211

백준 C# - 2941 StringBuilder 알아보러 가기 C# - StringBuilder String String 개체는 변경할 수 없다. System.String 클래스에서 메서드 중 하나를 사용할 때마다 메모리에 새 문자열 개체가 생성되므로, 새 개체에 대한 공간을 새로 할당 되어진다. 그러므로 문자열 code-piggy.tistory.com using System; using System.Collections.Generic; using System.Text; namespace baek2 { class Program { static void Main(string[] args) { string s1 = Console.ReadLine(); StringBuilder sb = new StringBuilder(s1); str.. 2023. 5. 15.
백준 C# - 4344 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace baek2 { class Program { static void Main(string[] args) { string c_string = Console.ReadLine(); int c = int.Parse(c_string); while(c>0) { string n_string = Console.ReadLine(); string[] token = n_string.Split(); int n = int.Parse(token[0]); int[] students = new int[n]; int total = 0; for(int i = 1; i (.. 2023. 5. 13.
C# - 소수점 자릿수(ToString,String.Format,Round) 사용자 지정 숫자 형식 문자 표준 숫자 서식 문자 소수점 두번째까지만 출력하는 방법 예시 1. ToString 01 pi.ToString("0.00") double pi = 3.14159265359; string result = pi.ToString("0.00"); Console.WriteLine($"pi.ToString 결과 : {result}"); 02 pi.ToString("n2") double pi = 3.14159265359; string result = pi.ToString("n2"); Console.WriteLine($"pi.ToString 결과 : {result}"); 2. String.Format 01 String.Format("{0:N2}", pi) double pi = 3.141592.. 2023. 5. 13.
백준 C# 1157 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace baek2 { class Program { static void Main(string[] args) { string input = Console.ReadLine(); string lower_input = input.ToUpper(); char[] arr = lower_input.ToArray(); Dictionary pig = new Dictionary(); for (int i = 0; i < input.Length; i++) { if (pig.ContainsKey(arr[i])) { pig[arr[i]] += 1; } else { p.. 2023. 5. 8.
백준 C# 10988 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace baek2 { class Program { static void Main(string[] args) { string input = Console.ReadLine(); int answer = 1; char[] string_1 = new char[input.Length]; char[] string_2 = new char[input.Length]; for (int i = 0; i < input.Length; i++) { string_1[i] = input[i]; } int count = 0; for(int i = input.Length; i.. 2023. 5. 8.
C# - 배열 연결, 덧붙이는 방법 (Enumerable.Concat() 사용) Enumerable.Concat() 두 시퀀스를 연결해 준다. public static System.Collections.Generic.IEnumerable Concat (this System.Collections.Generic.IEnumerable first, System.Collections.Generic.IEnumerable second); 매개변수 first : 연결할 첫번째 시퀀스 second : 연결할 두번째 시퀀스 01 한번 concat하는 경우 int[] first = { 1, 2, 3 }; int[] second = { 4, 5, 6 }; int[] example; example = first.Concat(second).ToArray(); 매개변수 first: 연결할 첫번째 시퀀스 sec.. 2023. 5. 3.
반응형