Advertisement
erfanul007

Untitled

Dec 5th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.72 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #include<string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. string a,x;
  8. int n,ln,spc;
  9. freopen("input.txt","r",stdin);
  10. cin>>n;
  11. int j,i=0,k,l;
  12. getchar();
  13. while(n--){
  14. i++;
  15. getline(cin, a);
  16. spc=0;
  17. k=0;
  18. ln=a.size();
  19. cout<<"Message #"<<i<<endl;
  20. for(j=0;j<ln;j++){
  21. if(a[j]==' ' && a[j-1]==' '){
  22. cout<<" ";
  23. k++;
  24. continue;
  25. }
  26. if(a[j]==' ' || j-1==ln){
  27. l=j-k;
  28. x.append(a,k,l);
  29. if(x.compare(".-")==0)
  30. cout<<"A";
  31. else if(x.compare("-...")==0)
  32. cout<<"B";
  33. else if(x.compare("-.-.")==0)
  34. cout<<"C";
  35. else if(x.compare("-..")==0)
  36. cout<<"D";
  37. else if(x.compare(".")==0)
  38. cout<<"E";
  39. else if(x.compare("..-.")==0)
  40. cout<<"F";
  41. else if(x.compare("--.")==0)
  42. cout<<"G";
  43. else if(x.compare("....")==0)
  44. cout<<"H";
  45. else if(x.compare("..")==0)
  46. cout<<"I";
  47. else if(x.compare(".---")==0)
  48. cout<<"J";
  49. else if(x.compare("-.-")==0)
  50. cout<<"K";
  51. else if(x.compare(".-..")==0)
  52. cout<<"L";
  53. else if(x.compare("--")==0)
  54. cout<<"M";
  55. else if(x.compare("-.")==0)
  56. cout<<"N";
  57. else if(x.compare("---")==0)
  58. cout<<"O";
  59. else if(x.compare(".--.")==0)
  60. cout<<"P";
  61. else if(x.compare("--.-")==0)
  62. cout<<"Q";
  63. else if(x.compare(".-.")==0)
  64. cout<<"R";
  65. else if(x.compare("...")==0)
  66. cout<<"S";
  67. else if(x.compare("-")==0)
  68. cout<<"T";
  69. else if(x.compare("..-")==0)
  70. cout<<"U";
  71. else if(x.compare("...-")==0)
  72. cout<<"V";
  73. else if(x.compare(".--")==0)
  74. cout<<"W";
  75. else if(x.compare("-..-")==0)
  76. cout<<"X";
  77. else if(x.compare("-.--")==0)
  78. cout<<"Y";
  79. else if(x.compare("--..")==0)
  80. cout<<"Z";
  81. else if(x.compare("-----")==0)
  82. cout<<"0";
  83. else if(x.compare(".----")==0)
  84. cout<<"1";
  85. else if(x.compare("..---")==0)
  86. cout<<"2";
  87. else if(x.compare("...--")==0)
  88. cout<<"3";
  89. else if(x.compare("....-")==0)
  90. cout<<"4";
  91. else if(x.compare(".....")==0)
  92. cout<<"5";
  93. else if(x.compare("-....")==0)
  94. cout<<"6";
  95. else if(x.compare("--...")==0)
  96. cout<<"7";
  97. else if(x.compare("---..")==0)
  98. cout<<"8";
  99. else if(x.compare("----.")==0)
  100. cout<<"9";
  101. else if(x.compare(".-.-.-")==0)
  102. cout<<".";
  103. else if(x.compare("--..--")==0)
  104. cout<<",";
  105. else if(x.compare("..--..")==0)
  106. cout<<"?";
  107. else if(x.compare(".----.")==0)
  108. cout<<"'";
  109. else if(x.compare("-.-.--")==0)
  110. cout<<"!";
  111. else if(x.compare("-..-.")==0)
  112. cout<<"/";
  113. else if(x.compare("-.–.")==0)
  114. cout<<"(";
  115. else if(x.compare("-.--.-")==0)
  116. cout<<")";
  117. else if(x.compare(".-...")==0)
  118. cout<<"&";
  119. else if(x.compare("---...")==0)
  120. cout<<":";
  121. else if(x.compare("-.-.-.")==0)
  122. cout<<";";
  123. else if(x.compare("-...-")==0)
  124. cout<<"=";
  125. else if(x.compare(".-.-.")==0)
  126. cout<<"+";
  127. else if(x.compare("-....-")==0)
  128. cout<<"-";
  129. else if(x.compare("..--.-")==0)
  130. cout<<"_";
  131. else if(x.compare(".-..-.")==0)
  132. cout<<"""";
  133. else if(x.compare(".--.-.")==0)
  134. cout<<"@";
  135. k=j+1;
  136. x.clear();
  137. }
  138. }
  139. cout<<endl;
  140. if(n)
  141. cout<<endl;
  142. }
  143. return 0;
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement