#include<iostream> #include<sstream> #include<cstdio> #include<cstdlib> #include<cstring> #include<map> #define db(a) cout << #a << " = " << a << endl; using namespace std; string evaluar(string buf){ return buf.size() == 2 ? " " : ""; } int main(){ mapmapa; mapa[".-"] = "A";mapa[".---"] = "J";mapa[".-."] = "R";mapa["--.."] = "Z";mapa["---.."] = "8"; mapa["-..."] = "B";mapa["-.-"] = "K";mapa["..."] = "S";mapa["-----"] = "0";mapa["----."] = "9"; mapa["-.-."] = "C";mapa[".-.."] = "L";mapa["-"] = "T";mapa[".----"] = "1";mapa[".-.-.-"] = "."; mapa["-.."] = "D";mapa["--"] = "M";mapa["..-"] = "U";mapa["..---"] = "2";mapa["--..--"] = ","; mapa["."] = "E";mapa["-."] = "N";mapa["...-"] = "V";mapa["...--"] = "3";mapa["..--.."] = "?"; mapa["..-."] = "F";mapa["---"] = "O";mapa[".--"] = "W";mapa["....-"] = "4";mapa[".----."] = "'"; mapa["--."] = "G";mapa[".--."] = "P";mapa["-..-"] = "X";mapa["....."] = "5";mapa["-.-.--"] = "!"; mapa["...."] = "H";mapa["--.-"] = "Q";mapa["-.--"] = "Y";mapa["-...."] = "6";mapa["-..-."] = "/"; mapa[".."] = "I";mapa["--.-"] = "Q";mapa["-.--.-"] = ")";mapa["--..."] = "7";mapa["-.--."] = "("; mapa[".-..."] = "&";mapa["---..."] = ":";mapa["-.-.-."] = ";";mapa["-...-"] = "=";mapa[".-.-."] = "+"; mapa["-....-"] = "-";mapa["..--.-"] = "_";mapa[".-..-."] = "\"";mapa[".--.-."] = "@";mapa[""] = ""; //freopen("ou.out", "w", stdout); int t = 0; char test[2]; string linea, res = "", buf, morse; cin.getline(test, 2, '\n'); t = atoi(test); for(int i = 0; i < t; i++){ getline(cin , linea); res = ""; buf = ""; morse = ""; for(int k = 0; k < linea.size(); k++){ if(linea[k] == ' ') { res += mapa[morse]; morse = ""; buf += ' '; } else{ res += evaluar(buf); buf = ""; morse += linea[k]; } } res += mapa[morse]; if(i + 1 == t) printf("Message #%d\n%s\n", i + 1, res.c_str()); else printf("Message #%d\n%s\n\n", i + 1, res.c_str()); } }
lunes, 24 de octubre de 2011
11223 - O: dah dah dah, uva
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario