[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]a227: 三龍杯 -> 河內之塔

建立 python 環境(windows 8)

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