Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- string input = "привет коля пошли бухать";
- MaxFind(input);
- }
- static void MaxFind(string text)
- {
- string[] str = text.Split(' '); // Разбиваем строку разделительными символами
- var maxLength = GetMaxLengthString(str);
- for (int i = 0; i < str.Length; i++)
- {
- if (str[i].Length == maxLength)
- {
- Console.Write(str[i] + " ");
- }
- }
- }
- private static int GetMaxLengthString(string[] str)
- {
- if (str.Length == 0) return 0;
- var maxLength = str[0].Length;
- for (int i = 1; i < str.Length; i++)
- {
- if (str[i].Length > maxLength)
- {
- maxLength = str[i].Length;
- }
- }
- return maxLength;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement