본문 바로가기
728x90

알고리즘123

[ 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++ ] 10699 오늘 날짜 https://www.acmicpc.net/problem/10699 10699번: 오늘 날짜 서울의 오늘 날짜를 출력하는 프로그램을 작성하시오. www.acmicpc.net 전에 풀어두고 제출 안 한 문제가 있어 올린다. #include #include int main() { std::time_t timer = time(NULL); //struct tm t; //localtime_s(&t, &timer); //t.tm_hour -= 3; //std::cout 2023. 8. 20.
728x90