[ZJ]b515: 摩斯電碼-商競103

題目:
http://zerojudge.tw/ShowProblem?problemid=b515
-----------------------------------------------------------------------------------------------------------------------

#include<bits/stdc++.h>
using namespace std ;

string s[]={".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."} ;
map<string,char> a ;

string str;
int main(){
    for (int i=0;i<26;i++)
        a[s[i]] = 'A' + i ;
    int T;
    scanf("%d",&T);
    getline(cin,str) ;
    while (T-- && getline(cin,str) ){
        stringstream ss;
        ss <<str;
        string cha;
        while (ss>>cha)
            cout <<a[cha];
puts("");
    }
    return 0;
}

留言

這個網誌中的熱門文章

[ZJ]b513: 判斷質數-商競103

[ZJ]d212: 東東爬階梯