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();
- List<string> output = new List<string>();
- string[] command = Console.ReadLine().Split().ToArray();
- while (command[0] != "Ready")
- {
- if (command[0] == "Add")
- {
- if (letters.Contains(command[1]))
- {
- output.Add(command[1]);
- }
- else
- {
- Console.WriteLine("Card not found.");
- }
- }
- else if (command[0] == "Insert")
- {
- int index = int.Parse(command[2]);
- if ((index >= 0 && index < letters.Count) && index < output.Count && letters.Contains(command[1]))
- {
- output.Insert(index, command[1]);
- }
- else
- {
- Console.WriteLine("Error!");
- }
- }
- else if (command[0] == "Remove")
- {
- if (output.Contains(command[1]))
- {
- output.Remove(command[1]);
- }
- else
- {
- Console.WriteLine("Card not found.");
- }
- }
- else if (command[0] == "Shuffle")
- {
- output.Reverse();
- }
- else if (command[0] == "Swap")
- {
- int index1 = output.IndexOf(command[1]);
- int index2 = output.IndexOf(command[2]);
- string tmp = output[index1];
- output[index1] = output[index2];
- output[index2] = tmp;
- }
- command = Console.ReadLine().Split().ToArray();
- }
- Console.WriteLine(string.Join(" ", output));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement