Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace fundamental14
- {
- class MainClass
- {
- public static void Main()
- {
- List<string> friends = Console.ReadLine().Split(", ").ToList();
- string input = string.Empty;
- while ((input = Console.ReadLine()) != "Report")
- {
- string[] array = input.Split();
- string command = array[0];
- if (command == "Blacklist")
- {
- string name = array[1];
- if (!friends.Contains(name))
- {
- Console.WriteLine($"{name} was not found.");
- }
- else
- {
- int bla = friends.IndexOf(name);
- friends.Insert(bla, "Blacklisted");
- friends.RemoveAt(bla + 1);
- Console.WriteLine($"{name} was blacklisted.");
- }
- }
- else if (command == "Error")
- {
- int index = int.Parse(array[1]);
- string current = friends[index];
- if(current != "Blacklisted" && current != "Lost")
- {
- friends.Insert(index, "Lost");
- friends.RemoveAt(index + 1);
- Console.WriteLine($"{current} was lost due to an error.");
- }
- }
- else if (command == "Change")
- {
- int change = int.Parse(array[1]);
- string newName = array[2];
- if (change >= 0 && change < friends.Count)
- {
- friends.Insert(change, newName);
- string oldName = friends[change + 1];
- friends.RemoveAt(change + 1);
- Console.WriteLine($"{oldName} changed his username to {newName}.");
- }
- }
- }
- int black = 0;
- int lost = 0;
- for (int i = 0; i < friends.Count; i++)
- {
- if (friends[i] == "Blacklisted")
- {
- black++;
- }
- if (friends[i] == "Lost")
- {
- lost++;
- }
- }
- Console.WriteLine($"Blacklisted names: {black}");
- Console.WriteLine($"Lost names: {lost}");
- Console.WriteLine(string.Join(" ", friends));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement