[백준] C# : 알파벳찾기 (10809번)

ssu_hyun·2022년 7월 21일
0

Data Structure & Algorithm

목록 보기
38/67
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Baekjoon
{
    class Program
    {
        static void Main(string[] args)
        {
            // 아스키 코드 알파벳 소문자 : 97 ~122
            string s = Console.ReadLine();
            for (int i = 97; i < 123; i++)
            {
                if (s.Contains(Convert.ToChar(i)))
                {
                    Console.Write(s.IndexOf(Convert.ToChar(i)));
                    Console.Write(" ");
                }
                else
                {
                    Console.Write("-1");
                    Console.Write(" ");
                }
            }

        }
    }
}
  • StringBuilder 사용도 가능
  • 아스키 코드
    • 알파벳 소문자 : 97 ~ 122
    • 알파벳 대문자 : 65 ~ 90
    • 숫자 0~9 : 48 ~ 57

0개의 댓글