Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Numerics;
- namespace exampreparation
- {
- class exam
- {
- static void Main(string[] args)
- {
- List<string> schedule = Console.ReadLine().Split(", ").ToList();
- string[] command = Console.ReadLine().Split(':').ToArray();
- while (command[0] != "course start")
- {
- if (command[0] == "Add")
- {
- if (!schedule.Contains(command[1]))
- {
- schedule.Add(command[1]);
- }
- }
- if (command[0] == "Insert")
- {
- int index = int.Parse(command[2]);
- if (!schedule.Contains(command[1]))
- {
- schedule.Insert(index, command[1]);
- }
- }
- if (command[0] == "Remove")
- {
- if (schedule.Contains(command[1]))
- {
- schedule.Remove(command[1]);
- if (schedule.Contains($"{command[1]}-Exercise"))
- {
- schedule.Remove($"{command[1]}-Exercise");
- }
- }
- if (schedule.Contains($"{command[1]}-Exercise"))
- {
- schedule.Remove($"{command[1]}-Exercise");
- }
- }
- if (command[0] == "Swap")
- {
- if ((schedule.Contains(command[1]) && schedule.Contains(command[2])))
- {
- int index1 = schedule.IndexOf(command[1]);
- int index2 = schedule.IndexOf(command[2]);
- schedule[index1] = command[2];
- schedule[index2] = command[1];
- if (schedule.Contains($"{command[1]}-Exercise") && schedule.Contains($"{command[2]}-Exercise"))
- {
- if (index1 + 1 < schedule.Count && index2 + 1 < schedule.Count)
- {
- int indEx1 = schedule.IndexOf($"{command[2]}-Exercise");
- schedule.RemoveAt(indEx1);
- int indEx2 = schedule.IndexOf($"{command[1]}-Exercise");
- schedule.RemoveAt(indEx2);
- schedule.Insert(index1 + 1, $"{command[2]}-Exercise");
- schedule.Insert(index2 + 1, $"{command[1]}-Exercise");
- }
- }
- else if (schedule.Contains($"{command[1]}-Exercise"))
- {
- if (index2 + 1 < schedule.Count)
- {
- int indEx = schedule.IndexOf($"{command[1]}-Exercise");
- schedule.RemoveAt(indEx);
- schedule.Insert(index2 + 1, $"{command[1]}-Exercise");
- }
- }
- else if (schedule.Contains($"{command[2]}-Exercise"))
- {
- if (index1 + 1 < schedule.Count)
- {
- int indEx = schedule.IndexOf($"{command[2]}-Exercise");
- schedule.RemoveAt(indEx);
- schedule.Insert(index1 + 1, $"{command[2]}-Exercise");
- }
- }
- }
- }
- if (command[0] == "Exercise")
- {
- string exercise = command[1] + '-' + "Exercise";
- if (schedule.Contains(command[1]) && (!schedule.Contains(command[0])))
- {
- int index = schedule.IndexOf(command[1]) + 1;
- schedule.Insert(index, exercise);
- }
- else if (!(schedule.Contains(command[0]) && schedule.Contains(command[1])))
- {
- schedule.Add(command[1]);
- schedule.Add(exercise);
- }
- }
- command = Console.ReadLine().Split(':').ToArray();
- }
- for (int i = 0; i < schedule.Count; i++)
- {
- Console.WriteLine($"{i + 1}.{schedule[i]}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement