Exercise: Lists - C# Fundamentals - 3. House Party
Здравейте,
може ли някой да помогне относно намиране
на причината Judge да дава 87 / 100 ?
using System;
using System.Collections.Generic;
using System.Linq;
namespace HouseParty
{
class Program
{
static void Main(string[] args)
{
int numOfGuests = 0;
string num = Console.ReadLine();
if (int.TryParse(num, out numOfGuests))
{
numOfGuests = int.Parse(num);
}
List<string> guests = new List<string>(numOfGuests * 2);
for (int i = numOfGuests - 1; i >= 0; i--)
{
string[] commands = Console.ReadLine()
.Split(" ", StringSplitOptions.RemoveEmptyEntries)
.ToArray();
if (commands.Length >= 3)
{
if (commands[2] == "going!" && guests.Count == 0)
{
guests.Add(commands[0]);
}
else if (commands[2] == "going!" && guests.Count > 0)
{
for (int j = 0; j < guests.Count; j++)
{
if (guests[j] == commands[0])
{
Console.WriteLine($"{commands[0]} is already in the list!");
break;
}
if (j == guests.Count - 1 && guests[j] != commands[0])
{
guests.Add(commands[0]);
break;
}
}
}
if (commands[2] == "not")
{
for (int j = 0; j < guests.Count; j++)
{
if (guests[j] == commands[0])
{
guests.RemoveAt(j);
break;
}
if (j == guests.Count - 1 && guests[j] != commands[0])
{
Console.WriteLine($"{commands[0]} is not in the list!");
break;
}
}
}
}
}
if (guests.Count > 0)
{
for (int i = 0; i < guests.Count; i++)
{
Console.WriteLine(guests[i]);
}
}
}
}
}