분류 전체보기(159)
-
[C#] 백준 2908번 상수
using System; namespace _7 { class Program { static void Main(string[] args) { string input = Console.ReadLine(); string[] array = input.Split(" "); char[] a = array[0].ToCharArray(); char[] b = array[1].ToCharArray(); Array.Reverse(a); Array.Reverse(b); string test; string test2; test = String.Concat(a); test2 = String.Concat(b); int first = Convert.ToInt32(test); int second = Convert.ToInt32(t..
2021.12.19 -
[C#] 백준 1152번 단어의 개수
using System; namespace _6 { class Program { static void Main(string[] args) { string input = Console.ReadLine(); string[] splitWord = input.Split(); int count = splitWord.Length; for (int i = 0; i < splitWord.Length; i++) { if (splitWord[i] == "") count -= 1; } Console.WriteLine(count); } } } 나중에 안 사실인데 C#에는 문자열 공백을 쉽게 해주는 메소드가 있다. Trim()은 앞, 뒤 공백 제거 TrimStart()은 앞 공백 제거 TrimEnd()는 뒤 공백 제거
2021.12.19 -
[C#] 백준 2675번 문자열 반복
using System; using System.Collections.Generic; namespace _4 { class Program { static void Main(string[] args) { int T = Convert.ToInt32(Console.ReadLine()); for (int l = 0; l < T; l++) { string input = Console.ReadLine(); string[] tmp = new string[2]; tmp = input.Split(" "); int R = Convert.ToInt32(tmp[0]); string S = tmp[1]; List array = new(); for (int i = 0; i < S.Length; i++) { for (int j =..
2021.12.19 -
[C#] 백준 1157번 단어 공부
using System; using System.Collections.Generic; using System.Linq; namespace _5 { class Program { static void Main(string[] args) { string input = Console.ReadLine(); string upper = input.ToUpper(); List inputList = new(); List checkWord = upper.Distinct().ToList(); int number = 0; char output = ' '; bool equalCheck = false; int count; if (input.Length > 1) { for (int i = 0; i < checkWord.Count;..
2021.12.19 -
[C#] 백준 10809번 알파벳 찾기
using System; namespace _3 { class Program { static void Main(string[] args) { char alpha = 'a'; string input = Console.ReadLine(); int ascii; string[] array = new string[26]; ascii = Convert.ToInt32(alpha); for (int i = 0; i < 26; i++) { for (int j = 0; j < input.Length; j++) { if (ascii == input[j] && array[i] == null) { array[i] = Convert.ToString(j); } } if (array[i] == null) array[i] = Conv..
2021.12.19 -
[C#] 백준 11720번 숫자의 합
using System; using System.Collections.Generic; namespace _2 { class Program { static void Main(string[] args) { int n = Convert.ToInt32(Console.ReadLine()); string input = Console.ReadLine(); int sum = RandAdd(n, input); Console.WriteLine(sum); } static public int RandAdd(int n, string input) { int sum = 0; for (int i = 0; i < input.Length; i++) { sum += Convert.ToInt32(input[i].ToString()); } ..
2021.12.19