Advertisement
erfanul007

UVa 11223

Dec 5th, 2018
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.99 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,cnt,cn;
  9. cin>>n;
  10. int j,i=0,k,l,z;
  11. getchar();
  12. while(n--){
  13. i++;
  14. getline(cin, a);
  15. a.insert(a.end(),1,' ');
  16. k=0;
  17. ln=a.size();
  18. cout<<"Message #"<<i<<endl;
  19. spc=0;
  20. cnt=0;
  21. cn=0;
  22. for(j=0;j<ln;j++){
  23. if(a[j]==' ' && a[j-1]==' '){
  24. if(cnt>0 && spc==0)
  25. cout<<" ";
  26. k++;
  27. spc++;
  28. continue;
  29. }
  30. if(cn==0 && a[j]!=' '){
  31. k=j;
  32. cn++;
  33. }
  34. if(a[j]==' ' && cn>0 ){
  35. l=j-k;
  36. x.append(a,k,l);
  37. if(x.compare(".-")==0)
  38. cout<<"A";
  39. else if(x.compare("-...")==0)
  40. cout<<"B";
  41. else if(x.compare("-.-.")==0)
  42. cout<<"C";
  43. else if(x.compare("-..")==0)
  44. cout<<"D";
  45. else if(x.compare(".")==0)
  46. cout<<"E";
  47. else if(x.compare("..-.")==0)
  48. cout<<"F";
  49. else if(x.compare("--.")==0)
  50. cout<<"G";
  51. else if(x.compare("....")==0)
  52. cout<<"H";
  53. else if(x.compare("..")==0)
  54. cout<<"I";
  55. else if(x.compare(".---")==0)
  56. cout<<"J";
  57. else if(x.compare("-.-")==0)
  58. cout<<"K";
  59. else if(x.compare(".-..")==0)
  60. cout<<"L";
  61. else if(x.compare("--")==0)
  62. cout<<"M";
  63. else if(x.compare("-.")==0)
  64. cout<<"N";
  65. else if(x.compare("---")==0)
  66. cout<<"O";
  67. else if(x.compare(".--.")==0)
  68. cout<<"P";
  69. else if(x.compare("--.-")==0)
  70. cout<<"Q";
  71. else if(x.compare(".-.")==0)
  72. cout<<"R";
  73. else if(x.compare("...")==0)
  74. cout<<"S";
  75. else if(x.compare("-")==0)
  76. cout<<"T";
  77. else if(x.compare("..-")==0)
  78. cout<<"U";
  79. else if(x.compare("...-")==0)
  80. cout<<"V";
  81. else if(x.compare(".--")==0)
  82. cout<<"W";
  83. else if(x.compare("-..-")==0)
  84. cout<<"X";
  85. else if(x.compare("-.--")==0)
  86. cout<<"Y";
  87. else if(x.compare("--..")==0)
  88. cout<<"Z";
  89. else if(x.compare("-----")==0)
  90. cout<<"0";
  91. else if(x.compare(".----")==0)
  92. cout<<"1";
  93. else if(x.compare("..---")==0)
  94. cout<<"2";
  95. else if(x.compare("...--")==0)
  96. cout<<"3";
  97. else if(x.compare("....-")==0)
  98. cout<<"4";
  99. else if(x.compare(".....")==0)
  100. cout<<"5";
  101. else if(x.compare("-....")==0)
  102. cout<<"6";
  103. else if(x.compare("--...")==0)
  104. cout<<"7";
  105. else if(x.compare("---..")==0)
  106. cout<<"8";
  107. else if(x.compare("----.")==0)
  108. cout<<"9";
  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. else if(x.compare("-....-")==0)
  136. cout<<"-";
  137. else if(x.compare("..--.-")==0)
  138. cout<<"_";
  139. else if(x.compare(".-..-.")==0){
  140. char w='"';
  141. cout<<w;
  142. }
  143. else if(x.compare(".--.-.")==0)
  144. cout<<"@";
  145. k=j+1;
  146. cnt++;
  147. spc=0;
  148. x.clear();
  149. }
  150. }
  151. cout<<endl;
  152. if(n)
  153. cout<<endl;
  154. }
  155. return 0;
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement