Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace GuestList
- {
- class Program
- {
- static void Main(string[] args)
- {
- int commands = int.Parse(Console.ReadLine());
- List<string> invitations = new List<string>();
- for (int i = 0; i < commands; i++)
- {
- string line = Console.ReadLine();
- string[] currentGuest = line.Split(" ").ToArray();
- string name = currentGuest[0];
- string isGoing = "";
- for (int k = 1; k < currentGuest.Length; k++)
- {
- isGoing += currentGuest[k] + " ";
- }
- if (isGoing.Trim() == "is going!")
- {
- if (!invitations.Contains(name))
- {
- invitations.Add(name);
- }
- else
- Console.WriteLine($"{name} is already in the list!");
- }
- else if (isGoing.Trim() == "is not going!")
- {
- if (invitations.Contains(name))
- {
- invitations.Remove(name);
- }
- else
- {
- Console.WriteLine($"{name} is not in the list!");
- }
- }
- }
- Console.WriteLine(string.Join($"\n", invitations));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement