using System; using System.Collections.Generic; var route = new[] { new Stop("Elm Street", 0), new Stop("Museum", 4), new Stop("Riverside", 9), new Stop("Market", 13), new Stop("Station", 18), }; var destinations = new[] { "Elm Street", "Market", "Station", "Airport", }; Console.WriteLine("Route from Elm Street"); foreach (Stop stop in route) { Console.WriteLine(Describe(stop)); } Console.WriteLine(); Console.WriteLine("Destination lookup"); foreach (string destination in destinations) { Stop? stop = FindStop(route, destination); string result = stop is null ? "stop not found" : Describe(stop); Console.WriteLine($"{destination} -> {result}"); } static Stop? FindStop(IReadOnlyList route, string destination) { for (int index = 0; index < route.Count - 1; index++) { if (route[index].Name == destination) { return route[index]; } } return null; } static string Describe(Stop stop) { return $"{stop.Name} ({stop.MinutesFromStart} min)"; } record Stop(string Name, int MinutesFromStart); // Есть ли баги в этом коде?