본문 바로가기
반응형

분류 전체보기542

백준 C# - 1316 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) { int n = int.Parse(Console.ReadLine()); int count = 0; while (n>0) { n--; bool.. 2023. 5. 15.
백준 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.
운영체제 - Interlocked(Increment,Exchange,Add메서드 등) Interlocked 다중 쓰레드에서 공유하는 변수에 대한 원자 단위 연산을 제공 장점 RaceCondition 알아보러 가기 운영체제 - RaceCondition, Atomic RaceCondition 여러개의 쓰레드들이 공유 변수 동시 접근 시 실행 순서에 따라 결과값이 달라지는 문제 static int number = 0; static void Thread_1() { for (int i = 0; i < 100000; i++) number++; } static void Thread_2() { for (i code-piggy.tistory.com 연산 순서 보장하여RaceCondition을 방지할 수 있고 원자적 연산을 수행한다. 단점 연산 순서가 보장되어 있어서 느릴 수 있다. int number가 .. 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.
Unity - IPointer Interface(IPointerEnterHandler등) IPointer Interface IPointer Interface를 사용하기 위해 using UnityEngine.EventSystem을 추가해주어야 한다. 마우스 이벤트를 처리하는 인터페이스이다. using UnityEngine.EventSystems; 1. IPointerEnterHandler 마우스의 커서가 충돌 영역 안으로 들어 올때 호출 되는 콜백 함수 public void OnPointerEnter(EventSystems.PointerEventData eventData); 2. IPointerExitHandler 마우스의 커서가 충돌 영역 밖으로 나갈 때 호출 되는 콜백 함수 public void OnPointerExit(EventSystems.PointerEventData eventData.. 2023. 5. 12.
반응형