03. House Party
https://pastebin.com/WF0g2dBV
В judge ми дава 62/100, а никъде не мога да намеря грешка.
Някой, ако може да удари едно рамо ( :
https://pastebin.com/WF0g2dBV
В judge ми дава 62/100, а никъде не мога да намеря грешка.
Някой, ако може да удари едно рамо ( :
Demo code, ;-)
using System;
using System.Collections.Generic;
namespace houseParty
{
class Program
{
static void Main(string[] args)
{
List<string> partyGuests = new List<string>();
int n = int.Parse(Console.ReadLine());
for (int i = 0; i < n; i++)
{
string[] guests = Console.ReadLine().Split();
if (guests.Length == 3)
{
AddGuest(guests[0], partyGuests);
}
else if (guests.Length == 4)
{
DeleteGuest(guests[0], partyGuests);
}
}
foreach (var guest in partyGuests)
{
Console.WriteLine(guest);
}
}
static List<string> AddGuest(string name, List<string> partyGuests)
{
if (partyGuests.Contains(name) == true)
{
Console.WriteLine($"{name} is already in the list!");
}
else
{
partyGuests.Add(name);
}
return partyGuests;
}
static List<string> DeleteGuest(string name, List<string> partyGuests)
{
if (partyGuests.Contains(name) == true)
{
partyGuests.Remove(name);
}
else
{
Console.WriteLine($"{name} is not in the list!");
}
return partyGuests;
}
}
}