ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to thread

Discussion of Problem 1723. Sandro's Book

Reply 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# шо ни так??
Posted by kuvaldaman 20 May 2017 01:44
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;
        }
    }


JUDGE_ID
Subject