emilia98

Stateless

Aug 7th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.70 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _06.Stateless
  4. {
  5.     class Stateless
  6.     {
  7.         static void Main()
  8.         {
  9.             string state = Console.ReadLine();
  10.             string fiction = Console.ReadLine();
  11.  
  12.             while (true)
  13.             {
  14.                 while (fiction.Length > 0)
  15.                 {
  16.                     if (state.Length > 0)
  17.                     {
  18.                         state = state.Replace(fiction, "");
  19.  
  20.                         if (state.Length != 0)
  21.                         {
  22.                             if (state[0] == ' ' && state.Length >= 2)
  23.                             {
  24.                                 state = state.Remove(0, 1);
  25.                             }
  26.                             else if (state[state.Length - 1] == ' ' && state.Length >= 1)
  27.                             {
  28.                                 state = state.Remove(state.Length - 1, 1);
  29.                             }
  30.                         }
  31.                     }
  32.  
  33.                     fiction = fiction.Remove(0, 1);
  34.  
  35.                     if (fiction.Length == 0)
  36.                     {
  37.                         break;
  38.                     }
  39.                     fiction = fiction.Remove(fiction.Length - 1, 1);
  40.  
  41.                 }
  42.  
  43.                 if (state.Length == 0)
  44.                 {
  45.                     Console.WriteLine("(void)");
  46.                 }
  47.                 else
  48.                 {
  49.                     Console.WriteLine(state);
  50.                 }
  51.  
  52.                 state = Console.ReadLine();
  53.  
  54.                 if (state == "collapse")
  55.                 {
  56.                     break;
  57.                 }
  58.                 fiction = Console.ReadLine();
  59.             }
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment