Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. //19.02.2017 Problem:You will be given an integer N.On the next N lines, you will receive some strings.
  2. //The strings will be either:
  3. //• sequences of random characters
  4. //• or the command - "spin"
  5.  
  6. //If they are normal random characters, you should append them to one another in the cypher string.
  7. //If the command "spin" is entered, every string entered after it should be appended at the start
  8. //of the cypher string, if the command "spin" is entered again after that, you should again begin to append
  9. //them at the end of the cypher string. And so, the append direction changes each time you enter the command "spin".
  10. //If two equal strings are entered two consecutive times, the cypher resets - emptying the cypher string. This rule also applies to the "spin" command.
  11. //Note: the "spin" commands do not count towards the N count.
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Threading.Tasks;
  17.  
  18. namespace Cypher_Roulette
  19. {
  20. class cypher_toulette
  21. {
  22. static void Main(string[] args)
  23. {
  24. int n = int.Parse(Console.ReadLine());
  25. string cypherString = "";
  26. string buffer = "";
  27. string inputText = "";
  28. bool addBack = true;
  29. for (int i = 0; i <n; i++)
  30. {
  31. buffer = inputText;
  32. inputText = Console.ReadLine();
  33.  
  34. if (buffer == inputText)
  35. {
  36. cypherString = "";
  37. inputText = "";
  38.  
  39. }
  40.  
  41. if (inputText=="spin")
  42. {
  43. inputText = "";
  44. i--;
  45. addBack = !addBack;
  46. }
  47. if (addBack==true)
  48. {
  49. cypherString = cypherString + inputText;
  50. }
  51. else if (addBack==false)
  52. {
  53. cypherString = inputText + cypherString;
  54. }
  55. }
  56. Console.WriteLine(cypherString);
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement