fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. string s = " 1.2 3.4 5.6 8.9 ";
  8. int startIdx, endIdx = 0;
  9. while(true)
  10. {
  11. startIdx = endIdx;
  12. // no find_first_not_of in C#
  13. while (startIdx < s.Length && s[startIdx] == ' ') startIdx++;
  14. if (startIdx == s.Length) break;
  15. endIdx = s.IndexOf(' ', startIdx);
  16. if (endIdx == -1) endIdx = s.Length;
  17. // how to extract a double here?
  18. Console.WriteLine("|" + s.Substring(startIdx, endIdx - startIdx) + "|");
  19. }
  20. }
  21. }
Success #stdin #stdout 0.04s 36944KB
stdin
Standard input is empty
stdout
|1.2|
|3.4|
|5.6|
|8.9|