Advertisement
silvana1303

house party

Jun 3rd, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.35 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Numerics;
  5. using System.Text;
  6.  
  7. namespace exampreparation
  8. {
  9.     class exam
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int times = int.Parse(Console.ReadLine());
  14.  
  15.             List<string> isGoing = new List<string>();
  16.  
  17.             for (int i = 0; i < times; i++)
  18.             {
  19.                 List<string> input = Console.ReadLine().Split().ToList();
  20.  
  21.  
  22.                 if (input.Count == 3)
  23.                 {
  24.                     if (isGoing.Contains(input[0]))
  25.                     {
  26.                        
  27.                         Console.WriteLine($"{input[0]} is already in the list!");
  28.                     }
  29.                     else
  30.                     {
  31.                         isGoing.Add(input[0]);
  32.                     }
  33.                 }
  34.                 else
  35.                 {
  36.                     if (isGoing.Contains(input[0]))
  37.                     {
  38.                        
  39.                         isGoing.Remove(input[0]);
  40.                     }
  41.                     else
  42.                     {
  43.                         Console.WriteLine($"{input[0]} is not in the list!");
  44.                     }
  45.                 }
  46.  
  47.             }
  48.  
  49.             Console.WriteLine(string.Join(Environment.NewLine, isGoing));
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement