Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _06_02Friendlist_Maintenance_Array_MidExam_Done_
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] usernames = Console.ReadLine().Split(", ");
- string command = "";
- int index = 0;
- int blocklistCount = 0;
- int lostNamesCount = 0;
- string newName = "";
- while ((command = Console.ReadLine()) != "Report")
- {
- string[] arrayCommand = command.Split(" ");
- if (arrayCommand[0] == "Blacklist")
- {
- for (int i = 0; i < usernames.Length; i++)
- {
- if (arrayCommand[1] == usernames[i])
- {
- Console.WriteLine($"{usernames[i]} was blacklisted.");
- usernames[i] = "Blacklisted";
- blocklistCount++;
- break;
- }
- else if(i == usernames.Length - 1)
- {
- Console.WriteLine($"{arrayCommand[1]} was not found.");
- break;
- }
- }
- }
- else if (arrayCommand[0] == "Error")
- {
- index = int.Parse(arrayCommand[1]);
- if (usernames[index] == "Blacklisted" || usernames[index] == "Lost")
- {
- continue;
- }
- else
- {
- Console.WriteLine($"{usernames[index]} was lost due to an error.");
- usernames[index] = "Lost";
- lostNamesCount++;
- continue;
- }
- }
- else if (arrayCommand[0] == "Change")
- {
- index = int.Parse(arrayCommand[1]);
- newName = arrayCommand[2];
- if (index <= usernames.Length - 1)
- {
- Console.WriteLine($"{usernames[index]} changed his username to {newName}.");
- usernames[index] = newName;
- continue;
- }
- }
- }
- Console.WriteLine($"Blacklisted names: {blocklistCount}");
- Console.WriteLine($"Lost names: {lostNamesCount}");
- Console.WriteLine(string.Join(" ", usernames));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement