3.House Party
Здравейте,
изкарвам 62/100. помощ!
using System;
using System.Linq;
using System.Collections.Generic;
namespace House_Party
{
class Program
{
static void Main(string[] args)
{
int numOfCmd = int.Parse(Console.ReadLine());
List<string> people = new List<string>();
for (int i = 0; i < numOfCmd; i++)
{
string cmd = Console.ReadLine();
List<string> res = cmd.Split().ToList();
string name = res[0];
bool isFound = false;
if (cmd.Contains("is not going"))
{
for (int j = 0; j < people.Count; j++)
{
if (people[j] == name)
{
people.Remove(name);
isFound = true;
break;
}
}
if (isFound == false)
{
Console.WriteLine($"{name} is not in the list!");
}
}
else
{
if (people.Count == 0)
{
people.Add(name);
}
else
{
for (int j = 0; j < numOfCmd; j++)
{
if (people[j] == name)
{
Console.WriteLine($"{name} is already in the list!");
break;
}
else
{
people.Add(name);
break;
}
}
}
}
}
for (int k = 0; k < people.Count; k++)
{
Console.WriteLine(people[k]);
}
}
}
}