๐Ÿ‘ฉ‍๐Ÿ’ปProgramming/Coding Test

[C#] [BOJ#5622] ๋‹ค์ด์–ผ

taesooya 2022. 8. 8.

My Solution


using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] num = Console.ReadLine().ToCharArray();
            string[] alphabets = { "ABC", "DEF", "GHI", "JKL", "MNO", "PQRS", "TUV", "WXYZ" };
            int sum = 0;
            int position = 0;
            for (int i = 0; i < num.Length; i++)
            {
                for (int j = 0; j < alphabets.Length; j++)
                    if (alphabets[j].Contains(num[i].ToString()))
                    {
                        position = Array.IndexOf(alphabets, alphabets[j]);
                        position = position + 3;
                    }
                sum += position;
            }
            Console.WriteLine(sum);
        }
    }
}

๋Œ“๊ธ€