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