Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Stream_Of_Letters
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- string letter1 = "c";
- string letter2 = "o";
- string letter3 = "n";
- string result = "";
- string firstResult = "";
- string mainResult = "";
- int secretCommand = 0;
- bool findSecretCommand = false;
- int counter = 0;
- int countWord1 = 0;
- int countWord2 = 0;
- int countWord3 = 0;
- while (true)
- {
- string word = Console.ReadLine();
- if (word == "End")
- {
- break;
- }
- if (char.Parse(word) >= 'a' && char.Parse(word) <= 'z' || char.Parse(word) >= 'A' && char.Parse(word) <= 'Z')
- {
- result += word;
- }
- if (result.Contains(letter1))
- {
- countWord1++;
- if (countWord1 == 1)
- {
- result = result.Replace(letter1.ToString(), string.Empty);
- }
- }
- if (result.Contains(letter2))
- {
- countWord2++;
- if (countWord2 == 1)
- {
- result = result.Replace(letter2.ToString(), string.Empty);
- }
- }
- if (result.Contains(letter3))
- {
- countWord3++;
- if (countWord3 == 1)
- {
- result = result.Replace(letter3.ToString(), string.Empty);
- }
- }
- if (countWord1 >= 1 && countWord2 >= 1 && countWord3 >= 1) // намирам символите от тайната команда
- {
- // записвам думата
- findSecretCommand = true;
- if (findSecretCommand == true)
- {
- secretCommand++;
- }
- }
- if (findSecretCommand == true && secretCommand == 1)
- {
- counter++;
- if (counter == 1)
- {
- firstResult += result;
- countWord1 = 0;
- countWord2 = 0;
- countWord3 = 0;
- result = string.Empty;
- }
- else
- {
- mainResult += result;
- countWord1 = 0;
- countWord2 = 0;
- countWord3 = 0;
- result = string.Empty;
- }
- }
- secretCommand = 0;
- }
- Console.WriteLine(firstResult + " " + mainResult + " ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement