using System;
struct DATE
{
public int year;
public int month;
public int day;
}
struct NOTE2
{
public string Name;
public string TELE;
public DATE DATE;
}
class Program
{
static void Main()
{
NOTE2[] BLOCK2 = new NOTE2[7];
for (int i = 0; i < BLOCK2.Length; i++)
{
Console.WriteLine($"Человек {i + 1}:");
Console.Write("Фамилия и инициалы: ");
BLOCK2[i].Name = Console.ReadLine();
Console.Write("Номер телефона: ");
BLOCK2[i].TELE = Console.ReadLine();
Console.Write("Год рождения: ");
BLOCK2[i].DATE.year = int.Parse(Console.ReadLine());
Console.Write("Месяц рождения: ");
BLOCK2[i].DATE.month = int.Parse(Console.ReadLine());
Console.Write("День рождения: ");
BLOCK2[i].DATE.day = int.Parse(Console.ReadLine());
}
// Сортировка по первым трём цифрам телефона
Array.Sort(BLOCK2, (a, b) =>
{
string numA = a.TELE.Replace("+", "").Replace("-", "").Replace(" ", "");
string numB = b.TELE.Replace("+", "").Replace("-", "").Replace(" ", "");
return string.Compare(
numA.Substring(0, Math.Min(3, numA.Length)),
numB.Substring(0, Math.Min(3, numB.Length)));
});
Console.Write("\nВведите фамилию для поиска: ");
string surname = Console.ReadLine();
bool found = false;
foreach (NOTE2 person in BLOCK2)
{
if (person.Name.StartsWith(
surname, StringComparison.OrdinalIgnoreCase))
{
Console.WriteLine($"ФИО: {person.Name}");
Console.WriteLine($"Телефон: {person.TELE}");
Console.WriteLine(
$"Дата рождения: {person.DATE.day}." +
$"{person.DATE.month}.{person.DATE.year}");
found = true;
}
}
if (!found)
{
Console.WriteLine("Такого человека нет.");
}
}
}