코딩 테스트/BOJ

C# 2711 오타맨 고창영

s0002 2023. 1. 12. 15:18
using System;
using System.Collections.Generic;

namespace Study11
{
    class App
    {
        //생성자 
        public App()
        {
            //boj 2711 오타맨 고창영 
            Dictionary<int, string> dic = new Dictionary<int, string>(){
                { 4, "MISSPELL" },
                { 1, "PROGRAMMING" },
                { 7, "CONTEST" },
                { 3, "BALLOON" },
            };

            //여기서부터 작성 

            //틀린 위치와 문장을 저장하기 위한 변수
            int wrongPosition = 0;
            string wrongSentence = null; 

            foreach (KeyValuePair<int, string> pair in dic)
            {
                wrongPosition = pair.Key;
                wrongSentence = pair.Value;

                //틀린 문장의 틀린 위치만 빼고 출력한다
                for(int i=0; i < wrongSentence.Length; i++)
                {   
                    if(i!=wrongPosition-1)
                        Console.Write(wrongSentence[i]);
                }
                Console.WriteLine();               
            }      

            //출력 
            //MISPELL
            //ROGRAMMING
            //CONTES
            //BALOON
        }
    }
}

 

https://www.acmicpc.net/problem/2711

 

2711번: 오타맨 고창영

첫째 줄에 테스트 케이스의 개수 T(1<=T<=1,000)가 주어진다. 각 테스트 케이스는 한 줄로 구성되어 있다. 첫 숫자는 창영이가 오타를 낸 위치이고, 두 번째 문자열은 창영이가 친 문자열이다. 문자

www.acmicpc.net