Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Threading;
- namespace ConsoleApp1
- {
- class Exam
- {
- static void Main(string[] args)
- {
- List<string> letters = Console.ReadLine().Split("|").ToList();
- string[] command = Console.ReadLine().Split().ToArray();
- while (command[0] != "Done")
- {
- if (command[1] == "Left")
- {
- int index = int.Parse(command[2]);
- if (index > 0 && index < letters.Count)
- {
- string temp = letters[index];
- letters.RemoveAt(index);
- letters.Insert(index - 1, temp);
- }
- }
- else if (command[1] == "Right")
- {
- int index = int.Parse(command[2]);
- if (index >= 0 && index < letters.Count - 1)
- {
- string temp = letters[index];
- letters.RemoveAt(index);
- letters.Insert(index + 1, temp);
- }
- }
- else if (command[1] == "Even")
- {
- for (int i = 0; i < letters.Count; i++)
- {
- if (i % 2 == 0)
- {
- Console.Write(letters[i] + " ");
- }
- }
- Console.WriteLine();
- }
- else if (command[1] == "Odd")
- {
- for (int i = 0; i < letters.Count; i++)
- {
- if (i % 2 == 1)
- {
- Console.Write(letters[i] + " ");
- }
- }
- Console.WriteLine();
- }
- command = Console.ReadLine().Split().ToArray();
- }
- string word = string.Join("", letters);
- Console.WriteLine($"You crafted {word}!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement