fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string text="ABCD,ABCDABCD,ADCDS";
  9. string whatToFind = "BC";
  10.  
  11. List<int> result = new List<int>();
  12. for(int index=0; index < text.Length; index++)
  13. {
  14. if(index + whatToFind.Length > text.Length)
  15. break;
  16. bool matches = true;
  17. for(int index2=0; index2<whatToFind.Length; index2++)
  18. {
  19. matches = text[index+index2] == whatToFind[index2];
  20. if(!matches)
  21. break;
  22. }
  23. if(matches)
  24. result.Add(index);
  25. }
  26. foreach(int index in result)
  27. Console.WriteLine(index);
  28. }
  29. }
Success #stdin #stdout 0.04s 37024KB
stdin
Standard input is empty
stdout
1
6
10