본문 바로가기

공부3

[C#][Study][기초다지기] lock 문 lock 문 - 현재 thread에서 프로그램을 실행하는동안 다른 thread의 개체를 잠그고, 진행되던 thread의 실행이 끝난 뒤에 개체의 잠금이 해제되어 다음 thread를 실행할 수 있게 함 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Lock_Statement { class Program { public void printname() { Console.WriteLine("My name is Steven Clark"); } static void Main(string[] args) { Program p = new Program(); lock (p) // lock 구문 생성.. 2023. 9. 23.
[C#][Study][기초다지기] goto 문 goto 문 - label을 선언한 곳으로 돌아감 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace goto_statements { class Program { static void Main(string[] args) { string name; label: // 레이블 생성 -> 콜론 주의! Console.WriteLine("Enter your name: "); name = Console.ReadLine(); Console.WriteLine("Welcome {0}", name); Console.WriteLine("Press Ctrl + C for Exit\n"); goto label;.. 2023. 9. 23.
[프로그래머스][C++] 덧칠하기 #include #include using namespace std; int solution(int n, int m, vector section) { int answer = 0; int index = 0; for(int i = section[index++]; i 리턴 if(index >= section.size()) return answer; } i = section[index]; // 현재 섹션을 반복자로 재정의 } return answer; } 1. answer과 index를 선언 2. 반복자 i가 섹션의 0번째 인덱스부터 시작해 n이 될 때까지 반복을 진행한다. 3. 매 반복은 페인트칠을 하는 횟수를 의미하므로 answer을 1씩 증가시킨다. 4. 이후 섹션의 다음 수가 현재 수에 롤러의 길이를 더.. 2023. 9. 13.