Skip to content

Instantly share code, notes, and snippets.

@unilecs
Last active January 16, 2024 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unilecs/f687e0dc768fcd9fcd488672eced478e to your computer and use it in GitHub Desktop.
Save unilecs/f687e0dc768fcd9fcd488672eced478e to your computer and use it in GitHub Desktop.
Задача: Максимальное число в подстроке
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