👩‍💻Programming/Coding Test

[C#] [BOJ#10809] 알파벳 찾기

taesooya 2022. 8. 8.

My Solution


using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            char[] ss = s.ToCharArray();
            string alphab = "abcdefghijklmnopqrstuvwxyz";
            char[] alphabets = alphab.ToCharArray();

            for (int i = 0; i < 26; i++)
            {
                int position = Array.IndexOf(ss, alphabets[i]);
                Console.WriteLine(position);
            }
        }
    }
}

 

 

Solution

  • char이 ++이 가능하다니....

using System;
using System.Text;

namespace Test1
{
    public class Test
    {
        public static void Main(string[] args)
        {
            string input = Console.ReadLine();
            StringBuilder sb = new StringBuilder();
            for (char c = 'a'; c <= 'z'; c++)
            {
                sb.Append(input.IndexOf(c) + " ");
            }
            Console.WriteLine(sb);
        }
    }
}

'👩‍💻Programming > Coding Test' 카테고리의 다른 글

[C#] [BOJ#2675] 문자열반복  (0) 2022.08.13
[C#] [BOJ#2908] 상수  (0) 2022.08.08
[C#] [BOJ#11720] 숫자의 합  (0) 2022.08.08
[C#] [BOJ#5622] 다이얼  (0) 2022.08.08
[C#] [BOJ#2941] 크로아티아 알파벳  (0) 2022.08.08

댓글