[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;
}
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;
}
留言
張貼留言