본문 바로가기
반응형

전체 글500

백준 C# 2439 using System; using System.Text; namespace baek2 { class Program { static void Main(string[] args) { string n_input = Console.ReadLine(); int N = int.Parse(n_input); for (int i=1; i 2023. 4. 9.
백준 C# 2438 using System; using System.Text; namespace baek2 { class Program { static void Main(string[] args) { string n_input = Console.ReadLine(); int N = int.Parse(n_input); for (int i=1; i 2023. 4. 9.
백준 C# 11022 StringBuilder 개념 알아보러 가기 StringBuilder String String 개체는 변경할 수 없다. System.String 클래스에서 메서드 중 하나를 사용할 때마다 메모리에 새 문자열 개체가 생성되므로, 새 개체에 대한 공간을 새로 할당 되어진다. 그러므로 문자열 code-piggy.tistory.com using System; using System.Text; namespace baek2 { class Program { static void Main(string[] args) { StringBuilder sb = new StringBuilder(); string input_n = Console.ReadLine(); int n = int.Parse(input_n); int coun.. 2023. 4. 9.
백준 C# 11021 StringBuilder 개념 알아보러 가기 StringBuilder String String 개체는 변경할 수 없다. System.String 클래스에서 메서드 중 하나를 사용할 때마다 메모리에 새 문자열 개체가 생성되므로, 새 개체에 대한 공간을 새로 할당 되어진다. 그러므로 문자열 code-piggy.tistory.com using System; using System.Text; namespace baek2 { class Program { static void Main(string[] args) { StringBuilder sb = new StringBuilder(); string input_n = Console.ReadLine(); int n = int.Parse(input_n); int coun.. 2023. 4. 9.
C# - StringBuilder String String 개체는 변경할 수 없다. System.String 클래스에서 메서드 중 하나를 사용할 때마다 메모리에 새 문자열 개체가 생성되므로, 새 개체에 대한 공간을 새로 할당 되어진다. 그러므로 문자열을 반복적으로 수정해야 하는 경우 메모리 낭비가 발생되어 비효율적인 코드가 생성된다. string example = "string"; Console.WriteLine(example); example = "Hello"; Console.WriteLine(example); StringBuilder 01 System.Text 네임 스페이스 가져오기 StringBuilder 클래스는 System.Text 네임스페이스에 있으므로 using문에 System.Text를 추가한다. using System; .. 2023. 4. 9.
백준 C# 15552 using System; namespace baek2 { class Program { static void Main(string[] args) { string input_n = Console.ReadLine(); int n = int.Parse(input_n); while(n>0) { string input_AB = Console.ReadLine(); string[] AB = input_AB.Split(); int A = int.Parse(AB[0]); int B = int.Parse(AB[1]); Console.WriteLine(A+B); n--; } } } } 위의 코드로 제출을 하고 난 후 시간초과 결과를 받았다. 문제를 다시 읽어 보니 아래와 같은 안내가 있었다. C# StreamReader로 읽.. 2023. 4. 9.
반응형