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