Advertisement
spasnikolov131

Untitled

Jan 17th, 2024
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Stream_Of_Letters
  4. {
  5. internal class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9.  
  10.  
  11.  
  12. string letter1 = "c";
  13. string letter2 = "o";
  14. string letter3 = "n";
  15.  
  16. string result = "";
  17.  
  18. string firstResult = "";
  19. string mainResult = "";
  20.  
  21. int secretCommand = 0;
  22. bool findSecretCommand = false;
  23.  
  24. int counter = 0;
  25. int countWord1 = 0;
  26. int countWord2 = 0;
  27. int countWord3 = 0;
  28.  
  29.  
  30. while (true)
  31. {
  32. string word = Console.ReadLine();
  33.  
  34.  
  35. if (word == "End")
  36. {
  37. break;
  38. }
  39.  
  40. if (char.Parse(word) >= 'a' && char.Parse(word) <= 'z' || char.Parse(word) >= 'A' && char.Parse(word) <= 'Z')
  41. {
  42. result += word;
  43. }
  44.  
  45.  
  46.  
  47.  
  48. if (result.Contains(letter1))
  49. {
  50. countWord1++;
  51.  
  52. if (countWord1 == 1)
  53. {
  54. result = result.Replace(letter1.ToString(), string.Empty);
  55. }
  56.  
  57. }
  58.  
  59. if (result.Contains(letter2))
  60. {
  61. countWord2++;
  62.  
  63. if (countWord2 == 1)
  64. {
  65. result = result.Replace(letter2.ToString(), string.Empty);
  66. }
  67.  
  68. }
  69.  
  70. if (result.Contains(letter3))
  71. {
  72. countWord3++;
  73.  
  74. if (countWord3 == 1)
  75. {
  76. result = result.Replace(letter3.ToString(), string.Empty);
  77. }
  78.  
  79. }
  80.  
  81. if (countWord1 >= 1 && countWord2 >= 1 && countWord3 >= 1) // намирам символите от тайната команда
  82. {
  83.  
  84. // записвам думата
  85. findSecretCommand = true;
  86.  
  87. if (findSecretCommand == true)
  88. {
  89. secretCommand++;
  90.  
  91. }
  92.  
  93.  
  94.  
  95.  
  96.  
  97. }
  98.  
  99.  
  100. if (findSecretCommand == true && secretCommand == 1)
  101. {
  102. counter++;
  103. if (counter == 1)
  104. {
  105. firstResult += result;
  106. countWord1 = 0;
  107. countWord2 = 0;
  108. countWord3 = 0;
  109. result = string.Empty;
  110. }
  111. else
  112. {
  113. mainResult += result;
  114. countWord1 = 0;
  115. countWord2 = 0;
  116. countWord3 = 0;
  117. result = string.Empty;
  118. }
  119.  
  120. }
  121.  
  122.  
  123.  
  124. secretCommand = 0;
  125.  
  126. }
  127. Console.WriteLine(firstResult + " " + mainResult + " ");
  128.  
  129. }
  130.  
  131. }
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement