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,cnt,cn;
- cin>>n;
- int j,i=0,k,l,z;
- getchar();
- while(n--){
- i++;
- getline(cin, a);
- ln=a.size();
- a.insert(a.end(),1,' ');
- k=0;
- ln=a.size();
- cout<<"Message #"<<i<<endl;
- spc=0;
- cnt=0;
- cn=0;
- for(j=0;j<ln;j++){
- if(a[j]==' ' && a[j-1]==' '){
- if(cnt>0 && spc==0)
- cout<<" ";
- k++;
- spc++;
- continue;
- }
- if(cn==0 && a[j]!=' '){
- k=j;
- cn++;
- }
- if(a[j]==' ' && cn>0 ){
- 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){
- char w='"';
- cout<<w;
- }
- else if(x.compare(".--.-.")==0)
- cout<<"@";
- k=j+1;
- cnt++;
- spc=0;
- x.clear();
- }
- }
- cout<<endl;
- if(n)
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement