Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace MIdExam
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11.  
  12. List<string> weapon = Console.ReadLine().Split("|").ToList();
  13. while (true)
  14. {
  15. string[] elements = Console.ReadLine().Split();
  16. //int index = int.Parse(elements[2]);
  17. if (elements[0] == "Done") break;
  18.  
  19. if (elements[0] == "Move")
  20. {
  21. if (elements[1] == "Left" && int.Parse(elements[2]) >= 1 && int.Parse(elements[2]) <= weapon.Count - 1)
  22. {
  23. weapon.Insert(int.Parse(elements[2]) - 1, weapon[int.Parse(elements[2])]);
  24. weapon.RemoveAt(int.Parse(elements[2])+1);
  25.  
  26. }
  27. if (elements[1] == "Right" && int.Parse(elements[2]) <= weapon.Count - 2 && int.Parse(elements[2]) >= 0)
  28. {
  29. weapon.Insert(int.Parse(elements[2]) + 2, weapon[int.Parse(elements[2])]);
  30. weapon.RemoveAt(int.Parse(elements[2]));
  31. }
  32.  
  33. }
  34. if (elements[0] == "Check")
  35. {
  36. if (elements[1] == "Even")
  37. {
  38. for (int i = 0; i < weapon.Count; i+=2)
  39. {
  40.  
  41. Console.Write(weapon[i] + " ");
  42. }
  43. Console.WriteLine();
  44. }
  45. if (elements[1] == "Odd")
  46. {
  47. for (int i = 1; i < weapon.Count; i+=2)
  48. {
  49.  
  50. Console.Write(weapon[i] + " ");
  51.  
  52. }
  53. Console.WriteLine();
  54. }
  55. }
  56.  
  57.  
  58. }
  59. Console.WriteLine($"You crafted {string.Join("", weapon)}!");
  60.  
  61. }
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement