Guest User

03. Stream Of Letters

a guest
Oct 21st, 2019
926
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.35 KB | None | 0 0
  1. using System;
  2.  
  3. namespace StreamOfLetters
  4. {
  5.     class StreamOfLetters
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string expression, result = "";
  10.             bool isItCCommand = false, isItOCommand = false, isItNCommand = false;
  11.  
  12.             while (true)
  13.             {
  14.  
  15.                 expression = Console.ReadLine();
  16.  
  17.                 if (isItCCommand == true && isItNCommand == true && isItOCommand == true)
  18.                 {
  19.                     Console.Write(result + " ");
  20.                     result = "";
  21.                     isItCCommand = false;
  22.                     isItNCommand = false;
  23.                     isItOCommand = false;
  24.                 }
  25.  
  26.                 if (expression.Equals("End"))
  27.                 {
  28.                     break;
  29.                 }
  30.  
  31.                 char letter = char.Parse(expression);
  32.  
  33.                 if (((int)letter >= 65 && (int)letter <= 90) || ((int)letter >= 97 && (int)letter <= 122))
  34.                 {
  35.  
  36.                     if (letter == 'c' && isItCCommand == false)
  37.                     {
  38.                         isItCCommand = true;
  39.                         continue;
  40.                     }
  41.                     else if (letter == 'c' && isItCCommand == true)
  42.                     {
  43.                         result = result + "" + letter;
  44.                         continue;
  45.                     }
  46.  
  47.                     if (letter == 'o' && isItOCommand == false)
  48.                     {
  49.                         isItOCommand = true;
  50.                         continue;
  51.                     }
  52.                     else if (letter == 'o' && isItOCommand == true)
  53.                     {
  54.                         result = result + "" + letter;
  55.                         continue;
  56.                     }
  57.  
  58.                     if (letter == 'n' && isItNCommand == false)
  59.                     {
  60.                         isItNCommand = true;
  61.                         continue;
  62.                     }
  63.                     else if (letter == 'n' && isItNCommand == true)
  64.                     {
  65.                         result = result + "" + letter;
  66.                         continue;
  67.                     }
  68.  
  69.                     result = result + "" + letter;
  70.  
  71.                 }
  72.                 else
  73.                 {
  74.                     continue;
  75.                 }
  76.             }
  77.         }
  78.     }
  79. }
Add Comment
Please, Sign In to add comment