Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- map<string, char>r;
- r[".-"] = 'A', r["-..."] = 'B', r["-.-."] = 'C';
- r["-.."] = 'D', r["."] = 'E', r["..-."] = 'F';
- r["--."] = 'G', r["...."] = 'H', r[".."] = 'I';
- r[".---"] = 'J', r["-.-"] = 'K', r[".-.."] = 'L';
- r["--"] = 'M', r["-."] = 'N', r["---"] = 'O';
- r[".--."] = 'P', r["--.-"] = 'Q', r[".-."] = 'R';
- r["..."] = 'S', r["-"] = 'T', r["..-"] = 'U';
- r["...-"] = 'V', r[".--"] = 'W', r["-..-"] = 'X';
- r["-.--"] = 'Y', r["--.."] = 'Z', r["-----"] = '0';
- r[".----"] = '1', r["..---"] = '2', r["...--"] = '3';
- r["....-"] = '4', r["....."] = '5', r["-...."] = '6';
- r["--..."] = '7', r["---.."] = '8', r["----."] = '9';
- r[".-.-.-"] = '.', r["--..--"] = ',', r["..--.."] = '?';
- r[".----."] = '\'', r["-.-.--"] = '!', r["-..-."] = '/';
- r["-.--."] = '(', r["-.--.-"] = ')', r[".-..."] = '&';
- r["---..."] = ':', r["-.-.-."] = ';', r["-...-"] = '=';
- r[".-.-."] = '+', r["-....-"] = '-', r["..--.-"] = '_';
- r[".-..-."] = '\"', r[".--.-."] = '@';
- int t, ca=1;
- cin>>t;
- string in;
- cin.ignore(100, '\n');
- while (t--) {
- cout<<"Message #"<<ca++<<endl;
- //getchar();
- getline(cin, in);
- int cnt=0, l=in.length();
- for (int i=0; in[i]; i++) {
- if (isspace(in[i])) {
- if (cnt==1) {
- cout<<" ";
- cnt=0;
- }
- else cnt++;
- continue;
- }
- string s="";
- int j=i;
- while (!isspace(in[j]) && j<l) {
- s.push_back(in[j++]);
- }
- cout<<r[s];
- cnt=0, i=j-1;
- }
- cout<<endl;
- if (t!=0)
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement