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> shops = Console.ReadLine().Split().ToList();
- int count = int.Parse(Console.ReadLine());
- for (int i = 0; i < count; i++)
- {
- string[] command = Console.ReadLine().Split().ToArray();
- if (command[0] == "Include")
- {
- shops.Add(command[1]);
- }
- if (command[1] == "first")
- {
- int shopCount = int.Parse(command[2]);
- if (shops.Count >= shopCount)
- {
- shops.RemoveRange(0, shopCount);
- }
- }
- if (command[1] == "last")
- {
- int shopCount = int.Parse(command[2]);
- if (shops.Count >= shopCount)
- {
- shops.Reverse();
- shops.RemoveRange(0, shopCount);
- shops.Reverse();
- }
- }
- if (command[0] == "Prefer")
- {
- int firstShop = int.Parse(command[1]);
- int secondShop = int.Parse(command[2]);
- if (firstShop >= 0 && firstShop < shops.Count && (secondShop >= 0 && secondShop < shops.Count))
- {
- string temp = shops[firstShop];
- shops[firstShop] = shops[secondShop];
- shops[secondShop] = temp;
- }
- }
- if (command[0] == "Place")
- {
- int index = int.Parse(command[2]) + 1;
- if (index >= 0 && index < shops.Count)
- {
- shops.Insert(index, command[1]);
- }
- }
- }
- Console.WriteLine("Shops left:");
- Console.WriteLine(string.Join(" ", shops));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement