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);
}
}
}
'๐ฉโ๐ปProgramming > Coding Test' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[C#] [BOJ#10809] ์ํ๋ฒณ ์ฐพ๊ธฐ (0) | 2022.08.08 |
---|---|
[C#] [BOJ#11720] ์ซ์์ ํฉ (0) | 2022.08.08 |
[C#] [BOJ#2941] ํฌ๋ก์ํฐ์ ์ํ๋ฒณ (0) | 2022.08.08 |
[C#] [BOJ#1157] ๋จ์ด์ ๊ฐ์ - Matches (0) | 2022.07.30 |
[C#] [BOJ#1157] ๋จ์ด ๊ณต๋ถ (0) | 2022.07.30 |
๋๊ธ