using System;
namespace MyCompiler {
class Program {
public static void Main(string[] args)
{
Console.WriteLine("Hello world!");
string ms = "ababababbaba";
string ss = "aba";
string index = "";
// occurrence - 3
// at indexes: 0,4,9
for(int i = 0; i < ms.Length ;i++)
{
string sub = "";
for(int j = i;j < i + ss.Length;j++)
{
if(j >= ms.Length)
{
i = ms.Length -1;
break;
}
sub += ms[j];
if(sub.Length == ss.Length && sub == ss)
{
index += index.Length != 0 ? ","+i.ToString() : i.ToString() ;
i = i + ss.Length < ms.Length ? i + ss.Length : i;
}
}
}
Console.WriteLine("String repreated at these indexes {0}",index);
Console.WriteLine("Number of times it repreated in the given string {0}",index.Split(",").Length);
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: