Last active
January 16, 2024 03:09
-
-
Save unilecs/f687e0dc768fcd9fcd488672eced478e to your computer and use it in GitHub Desktop.
Задача: Максимальное число в подстроке
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public class Program | |
{ | |
public static string FindLarge3DigitNum(string num) | |
{ | |
string result = ""; | |
for (int i = 0; i < num.Length - 2; i++) | |
{ | |
string curr = num.Substring(i, 3); | |
if (num[i] == num[i + 1] && num[i + 1] == num[i + 2] && string.Compare(result, curr) < 0) | |
{ | |
result = curr; | |
} | |
} | |
return result; | |
} | |
public static void Main() | |
{ | |
Console.WriteLine("UniLecs"); | |
// tests | |
Console.WriteLine(FindLarge3DigitNum("2300019")); // 000 | |
Console.WriteLine(FindLarge3DigitNum("5777144449")); // 777 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment