Source code for submission s643

fs.cpp

  1. #include <cstdio>
  2. #include <iostream>
  3. #include <sstream>
  4. #include <vector>
  5.  
  6. using namespace std;
  7. int super_delka=0;
  8.  
  9. char pole[30][5];
  10.  
  11. string funkce(char znak){
  12. switch(znak)
  13. {
  14. case 'A': return ".-";
  15. case 'B': return "-...";
  16. case 'C': return "-.-.";
  17. case 'D': return "-..";
  18. case 'E': return ".";
  19. case 'F': return "..-.";
  20. case 'G': return "--.";
  21. case 'H': return "....";
  22. case 'I': return "..";
  23. case 'J': return ".---";
  24. case 'K': return "-.-";
  25. case 'L': return ".-..";
  26. case 'M': return "--";
  27. case 'N': return "-.";
  28. case 'O': return "---";
  29. case 'P': return ".--.";
  30. case 'Q': return "--.-";
  31. case 'R': return ".-.";
  32. case 'S': return "...";
  33. case 'T': return "-";
  34. case 'U': return "..-";
  35. case 'V': return "...-";
  36. case 'W': return ".--";
  37. case 'X': return "-..-";
  38. case 'Y': return "-.--";
  39. case 'Z': return "--..";
  40. case '_': return "..--";
  41. case ',': return ".-.-";
  42. case '.': return "---.";
  43. case '?': return "----";
  44. }
  45. return "";
  46. }
  47.  
  48. void funkce2(string znak){
  49.  
  50.  
  51. if(!znak.compare(".-")) cout << "A";
  52. if(!znak.compare("-...")) cout << "B";
  53. if(!znak.compare("-.-.")) cout << "C";
  54. if(!znak.compare("-..")) cout << "D";
  55. if(!znak.compare(".")) cout << "E";
  56. if(!znak.compare("..-.")) cout << "F";
  57. if(!znak.compare("--.")) cout << "G";
  58. if(!znak.compare("....")) cout << "H";
  59. if(!znak.compare("..")) cout << "I";
  60. if(!znak.compare(".---")) cout << "J";
  61. if(!znak.compare("-.-")) cout << "K";
  62. if(!znak.compare(".-..")) cout << "L";
  63. if(!znak.compare("--")) cout << "M";
  64. if(!znak.compare("-.")) cout << "N";
  65. if(!znak.compare("---")) cout << "O";
  66. if(!znak.compare(".--.")) cout << "P";
  67. if(!znak.compare("--.-")) cout << "Q";
  68. if(!znak.compare(".-.")) cout << "R";
  69. if(!znak.compare("...")) cout << "S";
  70. if(!znak.compare("-")) cout << "T";
  71. if(!znak.compare("..-")) cout << "U";
  72. if(!znak.compare("...-")) cout << "V";
  73. if(!znak.compare(".--")) cout << "W";
  74. if(!znak.compare("-..-")) cout << "X";
  75. if(!znak.compare("-.--")) cout << "Y";
  76. if(!znak.compare("--..")) cout << "Z";
  77. if(!znak.compare("..--")) cout << "_";
  78. if(!znak.compare(".-.-")) cout << ",";
  79. if(!znak.compare("---.")) cout << ".";
  80. if(!znak.compare("----")) cout << "?";
  81.  
  82. }
  83.  
  84. int main(){
  85.  
  86. vector <int> krasno;
  87. string test;
  88.  
  89. while(cin>>test){
  90. krasno.clear();
  91. //string test = "FENDSVTSLHW.EDATS,EULAY";
  92. string test2 = "";
  93. string helper ="";
  94. string delka ="";
  95. for(unsigned int i =0 ; i < test.size(); i++)
  96. {
  97.  
  98. helper = funkce(test[i]);
  99.  
  100. krasno.push_back( (int)helper.size());
  101. test2.append(helper);
  102. }
  103. // cout << test2;
  104.  
  105. /*
  106. for( unsigned int i=0;i<krasno.size();i++)
  107. cout << krasno[i];
  108. */
  109.  
  110. int pom = 0;
  111. int pom2 = 0;
  112. for( unsigned int i=krasno.size()-1;i!=-1;i--)
  113. {
  114. pom = pom2;
  115. pom2 += krasno[i];
  116. funkce2(test2.substr(pom,krasno[i]));
  117. }
  118.  
  119. cout << endl;
  120. }
  121. return 0;
  122. }
  123.