Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //19.02.2017 Problem:You will be given an integer N.On the next N lines, you will receive some strings.
- //The strings will be either:
- //• sequences of random characters
- //• or the command - "spin"
- //If they are normal random characters, you should append them to one another in the cypher string.
- //If the command "spin" is entered, every string entered after it should be appended at the start
- //of the cypher string, if the command "spin" is entered again after that, you should again begin to append
- //them at the end of the cypher string. And so, the append direction changes each time you enter the command "spin".
- //If two equal strings are entered two consecutive times, the cypher resets - emptying the cypher string. This rule also applies to the "spin" command.
- //Note: the "spin" commands do not count towards the N count.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Cypher_Roulette
- {
- class cypher_toulette
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- string cypherString = "";
- string buffer = "";
- string inputText = "";
- bool addBack = true;
- for (int i = 0; i <n; i++)
- {
- buffer = inputText;
- inputText = Console.ReadLine();
- if (buffer == inputText)
- {
- cypherString = "";
- inputText = "";
- }
- if (inputText=="spin")
- {
- inputText = "";
- i--;
- addBack = !addBack;
- }
- if (addBack==true)
- {
- cypherString = cypherString + inputText;
- }
- else if (addBack==false)
- {
- cypherString = inputText + cypherString;
- }
- }
- Console.WriteLine(cypherString);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement