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> names = Console.ReadLine().Split().ToList();
- string[] command = Console.ReadLine().Split().ToArray();
- while (command[0] != "Print")
- {
- if (command[0] == "Add")
- {
- if (names.Contains(command[1]))
- {
- int index = int.Parse(command[2]);
- if (index >= 0 && index < names.Count)
- {
- names.Insert(index, command[1]);
- }
- }
- else
- {
- names.Add(command[1]);
- }
- }
- if (command[0] == "Remove")
- {
- int index = int.Parse(command[1]);
- if (index >= 0 && index < names.Count)
- {
- names.RemoveAt(index);
- }
- }
- if (command[0] == "Export")
- {
- int startIndex = int.Parse(command[1]);
- int count = int.Parse(command[2]);
- if (count > names.Count)
- {
- count = names.Count - startIndex;
- }
- List<string> export = names.GetRange(startIndex, count);
- Console.WriteLine(string.Join(" ", export));
- }
- command = Console.ReadLine().Split().ToArray();
- }
- if (command[1] == "Normal")
- {
- Console.WriteLine($"Contacts: {string.Join(" ", names)}");
- }
- else
- {
- names.Reverse();
- Console.WriteLine($"Contacts: {string.Join(" ", names)}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement