optybg

Untitled

Feb 1st, 2017
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.82 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _17.CypherRoulette
  4. {
  5.     public class CypherRoulette
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.            
  10.             int numberInputs = int.Parse(Console.ReadLine());
  11.             string newWord = "";
  12.             string prevWord = "";
  13.             string finalString = "";
  14.             int appendDirection = 0;
  15.  
  16.             for (int i = 0; i < numberInputs; i++)
  17.             {
  18.                
  19.                 newWord = Console.ReadLine();
  20.                                
  21.                 if (newWord == "spin") {
  22.                     if (appendDirection == 0) {
  23.                         appendDirection++;
  24.                         numberInputs++;
  25.                        
  26.                         continue;
  27.                     }
  28.                    
  29.                 }
  30.                 if (newWord == "spin") {
  31.                     if (appendDirection == 1)
  32.                     {
  33.                         appendDirection--;
  34.                         numberInputs++;
  35.                        
  36.                         continue;
  37.                     }
  38.                    
  39.                 }
  40.  
  41.                 if (i != 0)
  42.                 {
  43.                     if (prevWord == newWord)
  44.                     {
  45.                         finalString = "";
  46.  
  47.                         continue;
  48.                     }
  49.                 }
  50.  
  51.                 if (appendDirection == 0)
  52.                 {
  53.                     finalString = finalString + newWord;
  54.                     prevWord = newWord;
  55.                 }
  56.  
  57.                 if (appendDirection == 1)
  58.                 {
  59.                     finalString = newWord + finalString;
  60.                     prevWord = newWord;
  61.                 }
  62.                
  63.             }
  64.  
  65.             Console.WriteLine(finalString);
  66.         }
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment