fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. splits("Hello world!");
  8. }
  9.  
  10. // the funcion
  11. static void splits(string str)
  12. {
  13. int i=0;
  14. int count=0;
  15. string[] sent = new string[2];
  16. string buff= "";
  17. while (i < str.Length)
  18. {
  19. if (str[i] == ' ')
  20. {
  21. sent[count] = buff;
  22. count++;
  23. buff = "";
  24. }
  25. buff += str[i];
  26. i++;
  27. }
  28. if (!string.IsNullOrEmpty(buff))
  29. sent[count++] = buff;
  30. Console.WriteLine(sent[0]);
  31. Console.WriteLine(sent[1]);
  32. }
  33. }
Success #stdin #stdout 0.03s 36912KB
stdin
Standard input is empty
stdout
Hello
 world!