Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace KrushkovTask372
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- string[] cities = new string[5];
- InputCities(cities);
- string[] filtered = new string[5];
- filtered = FilterBySubstring(cities, "град");
- foreach (string s in filtered)
- {
- Console.WriteLine(s);
- }
- }
- static void InputCities(string[] cities)
- {
- for (int i = 0; i < cities.Length; i++)
- {
- Console.Write("Please enter city[{0}]: ", i);
- cities[i] = Console.ReadLine();
- }
- }
- static string[] FilterBySubstring(string[] cities, string substring)
- {
- string[] filtered = new string[cities.Length];
- for (int i = 0; i < cities.Length; i++)
- {
- if (cities[i].Contains(substring))
- {
- filtered[i] = cities[i];
- }
- }
- return filtered;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement