|
|
back to threadReply to message- Messages should be written in English and correspond to the matter of the website.
- Messages should not contain offences and obscene words.
- Messages should not contain correct solutions.
C# шо ни так?? class Program { static void Main(string[] args) { string result = AmountSubstring("tebidohtebidoh");
} static string AmountSubstring(string str1) { Go: string substring = ""; int amountSubstringStr = 0; int maxAmount = 0; string maxSubstring = ""; int g = 1; int i = 0; char[] arrayCharStr = new char[str1.Length]; foreach (var el in str1) { arrayCharStr[i] = el; i++; } substring = substring + arrayCharStr[0]; for (int l = 1; l < arrayCharStr.Length; l++) { substring += arrayCharStr[l]; amountSubstringStr = new Regex(substring).Matches(str1).Count; if (amountSubstringStr >= maxAmount) { maxAmount = amountSubstringStr; maxSubstring = substring; } } if (maxAmount < 2) { str1 = str1.Substring(g); g++; goto Go; } return maxSubstring; } }
|
|
|