Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace midprepare
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] arr = Console.ReadLine().Split('|');
- string command = Console.ReadLine();
- while (command != "Done")
- {
- string[] action = command.Split();
- if (action[0] == "Move")
- {
- int index = int.Parse(action[2]);
- if (action[1] == "Left")
- {
- if (index > 0 && index < arr.Length)
- {
- string temp = arr[index];
- arr[index] = arr[index - 1];
- arr[index - 1] = temp;
- }
- }
- if (action[1] == "Right")
- {
- if (index >= 0 && index < arr.Length - 1)
- {
- string temp = arr[index];
- arr[index] = arr[index + 1];
- arr[index + 1] = temp;
- }
- }
- }
- if (action[0] == "Check")
- {
- int n = 0;
- if (action[1] == "Odd")
- {
- n = 1;
- }
- for (int i = 0; i < arr.Length; i++)
- {
- if (i % 2 == n)
- {
- Console.Write(arr[i] + " ");
- }
- }
- Console.WriteLine();
- }
- command = Console.ReadLine();
- }
- Console.WriteLine($"You crafted { string.Join("", arr)}!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement