Aliendreamer

cypher roullete

Jun 7th, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.52 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace DataTypesAndVariables.Excercises17
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int wordsCount = int.Parse(Console.ReadLine());
  14.             string output = string.Empty;
  15.             string previousWord = string.Empty;
  16.             bool toEnd = true;
  17.             for (int i = 0; i < wordsCount; i++)
  18.             {
  19.                 string currentWord = Console.ReadLine();
  20.                 if (currentWord == "spin")
  21.                 {
  22.                     toEnd = !toEnd;
  23.                     i--;
  24.                 }
  25.                 switch (toEnd)
  26.                 {
  27.                     case (true): output += currentWord; break;
  28.                     case (false): output = currentWord + output; break;
  29.                 }
  30.                 if (currentWord == previousWord)
  31.                 {
  32.                     output = string.Empty;
  33.                     if (currentWord == "spin")
  34.                     {
  35.                         toEnd = !toEnd; //<- Why if i have two or more consecutive times spin I have to leave the direction the way it was before the first "spin"
  36.                     }
  37.                     previousWord = currentWord;
  38.                 }
  39.  
  40.                 previousWord = currentWord;
  41.             }
  42.             output = output.Replace("spin", string.Empty);
  43.             Console.WriteLine(output);
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment