작성일 :

문제 링크

30087번 - 진흥원 세미나

설명

신청한 세미나 이름이 주어질 때, 해당 세미나가 열리는 교실 번호를 출력하는 문제입니다.


접근법

세미나 이름과 교실 번호의 대응을 미리 저장해둡니다.

입력된 세미나 이름을 조회하여 교실 번호를 출력합니다.


Code

C#

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System;
using System.Collections.Generic;

class Program {
  static void Main() {
    var map = new Dictionary<string, string>() {
      {"Algorithm", "204"},
      {"DataAnalysis", "207"},
      {"ArtificialIntelligence", "302"},
      {"CyberSecurity", "B101"},
      {"Network", "303"},
      {"Startup", "501"},
      {"TestStrategy", "105"}
    };

    var n = int.Parse(Console.ReadLine()!);
    for (var i = 0; i < n; i++) {
      var key = Console.ReadLine()!;
      Console.WriteLine(map[key]);
    }
  }
}

C++

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  unordered_map<string, string> mp = {
    {"Algorithm", "204"},
    {"DataAnalysis", "207"},
    {"ArtificialIntelligence", "302"},
    {"CyberSecurity", "B101"},
    {"Network", "303"},
    {"Startup", "501"},
    {"TestStrategy", "105"}
  };

  int n; cin >> n;
  for (int i = 0; i < n; i++) {
    string s; cin >> s;
    cout << mp[s] << "\n";
  }

  return 0;
}

Tags: 30087, BOJ, C#, C++, 구현, 백준, 알고리즘

Categories: ,