본문 바로가기
728x90

c#102

[ BOJ/C# ] 3052 나머지 https://www.acmicpc.net/problem/3052 3052번: 나머지 각 수를 42로 나눈 나머지는 39, 40, 41, 0, 1, 2, 40, 41, 0, 1이다. 서로 다른 값은 6개가 있다. www.acmicpc.net using System; namespace _3052 { class Program { static void Main() { StreamReader sr = new StreamReader(Console.OpenStandardInput()); int[] inputs = new int[10]; int[] ints = new int[42]; int count = 0; for(int i = 0; i < 10; i++) { inputs[i] = int.Parse(sr.ReadL.. 2023. 8. 21.
[ BOJ/C# ] 2562 최댓값 https://www.acmicpc.net/problem/2562 2562번: 최댓값 9개의 서로 다른 자연수가 주어질 때, 이들 중 최댓값을 찾고 그 최댓값이 몇 번째 수인지를 구하는 프로그램을 작성하시오. 예를 들어, 서로 다른 9개의 자연수 3, 29, 38, 12, 57, 74, 40, 85, 61 이 주어 www.acmicpc.net List의 메서드를 사용하여 쉽게 풀 수 있다. using System; namespace _2562 { class Program { static void Main() { StreamReader sr = new StreamReader(Console.OpenStandardInput()); List ints = new List(); for(int i = 0; i < 9.. 2023. 8. 21.
[ BOJ/C# ] 1157 단어 공부 문자와 아스키코드를 이용하여 해결하였다. 아스키코드의 변환을 이용하는 것은 항상 재밌다! using System; namespace _1157 { class Program { static void Main() { string str = Console.ReadLine(); int[] n = new int[26]; if (str != null) { str = str.ToUpper(); //Console.WriteLine(str); char[] alphabets = str.ToCharArray(); for(int i = 0; i < alphabets.Length; i++) { //Console.WriteLine("i : {0}, alphabet : {1}", i, alphabets[i] - 65); n[alp.. 2023. 8. 20.
[ BOJ/C# ] 1550 16진수 https://www.acmicpc.net/problem/1550 1550번: 16진수 첫째 줄에 16진수 수가 주어진다. 이 수의 최대 길이는 6글자이다. 16진수 수는 0~9와 A~F로 이루어져 있고, A~F는 10~15를 뜻한다. 또, 이 수는 음이 아닌 정수이다. www.acmicpc.net Convert.ToInt32(string value, 16)으로 16진수를 10진수로 바꿔준다. using System; namespace _1550 { class Program { static void Main() { string input = Console.ReadLine(); int output = Convert.ToInt32(input, 16); Console.WriteLine(output); } } } 2023. 8. 20.
[ BOJ/C# ] 1330 두 수 비교하기 https://www.acmicpc.net/problem/1330 1330번: 두 수 비교하기 두 정수 A와 B가 주어졌을 때, A와 B를 비교하는 프로그램을 작성하시오. www.acmicpc.net using System; namespace _1330 { class Program { static void Main() { string[] abStr = (Console.ReadLine().Split(' ')); int a = int.Parse(abStr[0]); int b = int.Parse(abStr[1]); string ans = (a > b) ? ans = ">" : ((a == b) ? ans = "==" : ans = " 2023. 8. 20.
[ BOJ/C# ] 14503 로봇 청소기 BFS 문제 https://www.acmicpc.net/problem/14503 14503번: 로봇 청소기 첫째 줄에 방의 크기 $N$과 $M$이 입력된다. $(3 \le N, M \le 50)$ 둘째 줄에 처음에 로봇 청소기가 있는 칸의 좌표 $(r, c)$와 처음에 로봇 청소기가 바라보는 방향 $d$가 입력된다. $d$가 $0$인 경우 북쪽 www.acmicpc.net BFS에서 자주 사용되는 Queue를 사용할까 했지만 이차원배열로 푸는 방법이 머리속으로 딱 그려져 풀어보았다. BFS는 글로 먼저 적으며 나 자신도 이해하고 푸는 것이 중요하다고 생각한다. using System; using System.IO; namespace _14503 { class Program { static void Mai.. 2023. 8. 20.
728x90