---
# System prepended metadata

title: 3C 摩斯電碼
tags: [solution]

---

---
title: 3C 摩斯電碼
tags: solution
---

# C. 摩斯電碼

- 本題源自於ZeroJudge：[b515 - 摩斯電碼](https://zerojudge.tw/ShowProblem?problemid=b515)

Map 的練習用題，只要注意好所有摩斯電碼符號皆沒有拼寫錯誤即可。

```cpp=
# include <iostream>
# include <map>
# include <sstream>

using namespace std;

int main(){
    string morse_code[] = {".-", "-...", "-.-.", "-..", ".",
                           "..-.", "--.", "....", "..", ".---",
                           "-.-",".-..","--","-.","---",
                           ".--.","--.-",".-.","...","-",
                           "..-","...-",".--","-..-","-.--","--.."};

    map<string,char> morse;
    for( int x = 0 ; x<26 ; x++ )
        morse[morse_code[x]] = 'A'+x;

    int N;
    string s;

    cin>>N;
    getline(cin,s);
    while(N--){
        stringstream ss;
        getline(cin,s);
        ss<<s;

        while(ss>>s)
            cout<<morse[s];
        cout<<'\n';
    }
}
```