Advertisement
wigllytest

Untitled

Aug 15th, 2020
450
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.  
  7. string input = ""; //cin >> input;
  8. string output = "";
  9. string secretCommand = "";
  10. string text = "";
  11. string newWord = "";
  12.  
  13.  
  14. int charCounterC = 0;
  15. int charCounterO = 0;
  16. int charCounterN = 0;
  17.  
  18. while (input != "End")
  19. {
  20. cin >> input;
  21. for (int i = 0; i < input.size(); i++) {
  22.  
  23. // Finding the character whose
  24. // ASCII value fall under this
  25. // range
  26. if (input[i] < 'A' || input[i] > 'Z' &&
  27. input[i] < 'a' || input[i] > 'z')
  28. {
  29. // erase function to erase
  30. // the character
  31. input.erase(i, 1);
  32. i--;
  33. }
  34. }
  35.  
  36.  
  37. if (input != "End")
  38. {
  39.  
  40.  
  41. if (input == "c")
  42. {
  43. charCounterC++;
  44.  
  45. if (charCounterC > 1)
  46. {
  47. text += input;
  48. }
  49. else
  50. {
  51. text = text;
  52. secretCommand += input;
  53. }
  54. }
  55. else if (input == "o")
  56. {
  57. charCounterO++;
  58.  
  59. if (charCounterO > 1)
  60. {
  61. text += input;
  62. }
  63. else
  64. {
  65. text = text;
  66. secretCommand += input;
  67. }
  68. }
  69. else if (input == "n")
  70. {
  71. charCounterN++;
  72.  
  73. if (charCounterN > 1)
  74. {
  75. text += input;
  76. }
  77. else
  78. {
  79. text = text;
  80. secretCommand += input;
  81. }
  82.  
  83. }
  84. else
  85. {
  86. text += input;
  87. }
  88.  
  89. if (secretCommand == "con" || secretCommand == "cno" || secretCommand == "ocn" || secretCommand == "onc" || secretCommand == "nco" || secretCommand == "noc")
  90. {
  91. text += " ";
  92. output = text;
  93. secretCommand = "";
  94. charCounterC = 0;
  95. charCounterO = 0;
  96. charCounterN = 0;
  97. }
  98. }
  99. else
  100. {
  101. break;
  102. }
  103.  
  104. }
  105.  
  106. if (input == "End")
  107. {
  108. cout << output;
  109. }
  110.  
  111. return 0;
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement