fork(1) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. String x(String s){String o="";char c;int b=s.length(),d,i=-1,k=0;d=s.indexOf('.');d=d<0?b:d;if(b>1)while(++i<b)if((c=s.charAt(i))>48)o+=(k++>0?" + ":"")+(d-i>0?c:"0.")+(new String(new char[Math.abs(d-i)-1]).replace("\0","0"))+(d-i>0?"":c);return o;}
  8.  
  9. public static String x1(String s)
  10. {
  11. String o="";char c;int b=s.length(),d,i=-1,k=0;
  12. d=s.indexOf('.');d=d<0?b:d;
  13.  
  14. if(b>1)while(++i<b)
  15. if((c=s.charAt(i))>48)
  16. o+=(k++>0?" + ":"")
  17. +(d-i>0?c:"0.")
  18. +(new String(new char[Math.abs(d-i)-1]).replace("\0","0"))
  19. +(d-i>0?"":c);
  20.  
  21. return o;
  22. }
  23.  
  24. public static void main (String[] args) throws java.lang.Exception
  25. {
  26. System.out.println("9000.0009 = " + x1("9000.0009"));
  27. }
  28. }
Success #stdin #stdout 0.1s 320576KB
stdin
Standard input is empty
stdout
9000.0009 = 9000 + 0.0009