Algorithm/BOJ

Algorithm/BOJ

[프로그래머스] 전화번호 목록 C# 풀이

문제 풀이 using System; using System.Collections.Generic; namespace Programmers { class Program { static void Main() { string[] testcase = //테스트 케이스 문자열 배열 생성 후 초기화 { "12","123","1235","567","88" }; Solution sol = new Solution(); //솔루션 클래스 생성 List nums = new List(testcase); //테스트 케이스를 담을 문자열넘버 리스트 생성 bool result = sol.solution(nums); // 솔루션 클래스의 솔루션 매서드 사용 Console.WriteLine(result); // 결과 값 출력 } } c..

Algorithm/BOJ

[프로그래머스] 다트게임 C#풀이

문제 풀이 using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; namespace Programmers { class Program { static void Main() { string[] testcase = //테스트 점수 목록 { "1S2D*3T", "1D2S#10S", "1D2S0T", "1S*2T*3S", "1D#2S*3S", "1T2D3D#", "1D2S3T*" }; var sol = new Solution(); // 클래스 생성 //Console.WriteLine(testcase.Length); for (int i = 0; i < testcase.Length; i+..

Algorithm/BOJ

[BOJ] 10822 더하기 C# 사용 풀이

문제 풀이 using System; namespace 더하기 { class Program { static void Main() { string[] numList = { Console.ReadLine() }; numList = numList[0].Split(','); int sum = 0; foreach (string num in numList) { sum += Convert.ToInt32(num); } Console.WriteLine(sum); } } } 문제의 난이도 보다 foreach 문 부터 자동으로 작성해주는 비주얼 스튜디오 2022의 기능에 놀랐던 문제였다;;

Algorithm/BOJ

[BOJ] 1254 팰린드롬 만들기 c# 사용 풀이

문제 풀이 using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; namespace Two_Sum { class Program { static void Main() { string str = Console.ReadLine(); //문자 입력 string str2 = new string(str.Reverse().ToArray()); //입력받은 문자 뒤집기 if (str == str2) { Console.WriteLine(str.Length); } //입력받은 문자가 팰린드롬인지 아닌지 보기 else { for(int i = 0; i

Algorithm/BOJ

[BOJ] 1159 농구경기 c# 사용 문제풀이

문제 문제 풀이 using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; namespace Two_Sum { class Program { static void Main() { List list = new List() { "babic", "keksic", "boric", "bukic", "sarmic", "balic", "kruzic", "hrenovkic", "beslic", "boksic", "krafnic", "pecivic", "klavirkovic", "kukumaric", "sunkic", "kolacic", "kovacic..

Algorithm/BOJ

[BOJ] 1251 단어 나누기 C# 풀이

문제 문제 풀이 using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; namespace Two_Sum { class Program { static void Main() { string test = "mobitel"; //입력 문자열 List lists = new List(); //문자열 요소를 뒤집은뒤 합친 무낮열을 넣어줄 리스트 for(int i = 1;i

Algorithm/BOJ

[BOJ] 1439 뒤집기 C# 풀이

using System; using System.Linq; namespace _1439 { class Program { static void Main() { // 특정 수로 통일시키기 위해서, 0을 1로 바꾸거나 1을 0으로 바꿔야한다. // 연속된 하나 이상의 숫자를 모두 뒤집는 것이 가능하므로 // 연속된 숫자가 k개 있을 경우 k개를 한번에 뒤집는 것이 optimal solution이다. // 1이 연속되는 부분이 몇 개 있는지, 0이 연속되는 부분이 몇 개 있는지 확인한 다음 둘 중 가장 적은 것을 택하는 것이 답이 된다. var str = Console.ReadLine(); var arr = Array.ConvertAll(str.ToArray().Select(x => x.ToString()).T..

Algorithm/BOJ

[BOJ] 5585 거스름돈 C# 풀이

풀이 using System; using System.Collections.Generic; using System.Linq; namespace _5585 { class Program { static void Main() { int n = int.Parse(Console.ReadLine()); // 입력 문자열을 정수로 int r = 1000 - n; // r은 1000엔에서 n을 제외한 나머지 int[] arr = { 500, 100, 50, 10, 5, 1 }; // 잔돈 배열 int cnt = 0; for (int i = 0; i ..

Algorithm/BOJ

[BOJ] 1874 스택 수열 C# 풀이

문제 문제 풀이 using System; using System.Collections.Generic; namespace BOJ { class Program { static void Main() { int N = 8; // 수열의 최대 인덱스 입력 int[] numlist = { 4, 3, 6, 8, 7, 5, 2, 1 }; // 수열 인덱스의 요소 할당 Stack stacks = new Stack(); //수열과 비교할 스택 리스트 생성 List pmList = new List(); // 수열과 스택을 비교할때마다 넣어줄 "+" "-" 들을 담을문자열 리스트 int temp = 0; // 수열의 인덱스 초기화 for (int i = 1; i

Algorithm/BOJ

[BOJ] 1764 듣보잡 C# 알고리즘 풀이

듣잡과 보잡들중 듣보잡 2관왕을 가려내는 문제 문제풀이 using System; using System.Collections.Generic; namespace BOJ00 { class Program { static void Main(string[] args) { //듣잡 보잡 배열 string[] whoAreYouList = { "ohhenrie", "charlie", "baesangwook", "obama", "baesangwook", "ohhenrie", "clinton" }; //듣보잡들의 숫자를 셀 리스트 Dictionary nuguList = new Dictionary(); //듣잡 보잡들을 리스트에 담고 누가 듣보잡인지 세기 (2면 듣보잡, 1이면 듣잡 아님 보잡) foreach (string..

Bueong_E
'Algorithm/BOJ' 카테고리의 글 목록 (4 Page)