본문 바로가기

분류 전체보기98

좀비 프로세스란 좀비 프로세스에 대한 내용은 아래 사이트에 자세히 나와있다. https://www.joinc.co.kr/w/Site/system_programing/process/Zombie Zombie 프로세스 에 대한 고찰 Zombie 프로세스 에 대한 고찰참고문헌 waitpid(2), wait(2), fork(2), 시스템프로그래밍( www.joinc.co.kr 요약하자면, 자식 프로세스가 종료되었음에도 부모 프로세스에서 이에 대한 정보를 회수하지 않은 상태. 자식 프로세스가 return을 하든 exit을 하든 그것에 대한 자원은 모두 해제된다. 메모리나 CPU 등... 그러나 pcb(=task_struct)는 여전히 커널에 남아있게 된다. 부모 프로세스가 이를 필요로 할 수도 있기 때문이다. 부모 프로세스가 종료.. 2022. 8. 8.
백준 1436 C#) 영화감독 숌 또다시 각 자릿수를 추출하는 문제가 등장했다. public static class PS { public static void Main() { int n = int.Parse(Console.ReadLine()); int num = 666; int cnt = 0; while (true) { if (Check(num)) { if (++cnt == n) { Console.Write(num); return; } num += 1; } else { num += 3; } } } private static bool Check(int num) { int combo = 0; int digit; while (num > 0) { digit = num % 10; num /= 10; if (digit == 6) { if (++co.. 2022. 5. 28.
백준 1018 C#) 체스판 다시 칠하기 구현이 조금 까다로울 수도 있는 문제다. public static class PS { private static int m, n; private static char[][] board; static PS() { string[] mn = Console.ReadLine().Split(); m = int.Parse(mn[0]); n = int.Parse(mn[1]); board = new char[m][]; for (int i = 0; i < m; i++) { board[i] = Console.ReadLine().ToCharArray(); } } public static void Main() { int min = 32; for (int row = 0; row 2022. 5. 27.
백준 7568 C#) 덩치 복잡하게 생각할수록 잘 안풀리는 문제다. public static class PS { private static readonly int n; private static (int weight, int height)[] list; private static int[] rank; static PS() { n = int.Parse(Console.ReadLine()); list = new (int, int)[n]; rank = new int[n]; } public static void Main() { MakeList(); for (int i = 0; i < n; i++) { rank[i] = 1; for (int j = 0; j < n; j++) { if (i == j) continue; if (list[i].w.. 2022. 5. 25.
백준 2231 C#) 분해합 각 자릿수를 더하는 문제는 빈번하게 출제되므로 꼭 익혀두는 것이 좋다. public static class PS { public static void Main() { string ns = Console.ReadLine(); int n = int.Parse(ns); for (int m = n - ns.Length * 9; m 0) { sum += n % 10; n /= 10; } return sum; } } 이 문제를 풀다보면 문득 드는 생각이 하나 있다. 생성자의.. 2022. 5. 24.
백준 2798 C#) 블랙잭 브루트포스 단계의 첫 문제인 만큼 어렵지 않게 풀 수 있다. public static class PS { private readonly static int n, m; private static int[] cards; static PS() { string[] nm = Console.ReadLine().Split(); n = int.Parse(nm[0]); m = int.Parse(nm[1]); cards = Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } public static void Main() { int max = 0; int sum; for (int i = 0; i < n - 2; i++) { for (int j = i + 1; j < n .. 2022. 5. 24.
백준 11729 C#) 하노이 탑 이동 순서 재귀로 풀 수 있는 문제들 중에서도 상당히 유명한 편이다. public static class PS { private static readonly StreamWriter sw; static PS() { sw = new(new BufferedStream(Console.OpenStandardOutput())); } public static void Main() { int n = int.Parse(Console.ReadLine()); sw.WriteLine(Math.Pow(2, n) - 1); Hanoi(n, 1, 2, 3); sw.Close(); } private static void Hanoi(int n, int from, int via, int to) { if (n == 0) return; Hanoi(n.. 2022. 5. 19.
백준 17478 C#) 재귀함수가 뭔가요? 재귀가 이루어지는 과정을 머릿속에서 그릴 수 있어야 한다. static class Program { static StreamWriter sw; static string[] dialogues; static int n; static Program() { sw = new(new BufferedStream(Console.OpenStandardOutput())); dialogues = new[] {"____", "\"재귀함수가 뭔가요?\"", "\"잘 들어보게. 옛날옛날 한 산 꼭대기에 이세상 모든 지식을 통달한 선인이 있었어.", "마을 사람들은 모두 그 선인에게 수많은 질문을 했고, 모두 지혜롭게 대답해 주었지.", "그의 답은 대부분 옳았다고 하네. 그런데 어느 날, 그 선인에게 한 선비가 찾아와서 물었어... 2022. 5. 12.