Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _3._HouseParty
- {
- class HouseParty
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- List<string> guests = new List<string>();
- for (int i = 0; i < n; i++)
- {
- string input = Console.ReadLine();
- string[] splitedInput = input.Split(" ");
- string name = splitedInput[0];
- //if (splitedInput.Length == 3)
- if (splitedInput[1] == "is" && splitedInput[2] == "going!")
- {
- if (!guests.Contains(name))
- {
- guests.Add(name);
- }
- else
- {
- Console.WriteLine($"{name} is already in the list!");
- }
- }
- //if (splitedInput.Length == 4)
- if (splitedInput[2] == "not")
- {
- if (guests.Contains(name))
- {
- guests.Remove(name);
- }
- else
- {
- Console.WriteLine($"{name} is not in the list!");
- }
- }
- }
- Console.WriteLine(string.Join(Environment.NewLine, guests));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement