fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int[] x =
  13. { 14892093, 12344444, 112311, 888888, 135866667 };
  14. for (int i = 0; i < x.length; i++)
  15. System.out.println(x[i] + " -> " + w(x[i]));
  16. }
  17.  
  18. public static int w(int x)
  19. {
  20. int r = 0, d = x % 10;
  21. while (x % 10 == d)
  22. {
  23. r++;
  24. x /= 10;
  25. }
  26. return r;
  27. }
  28. }
Success #stdin #stdout 0.06s 3359744KB
stdin
Standard input is empty
stdout
14892093 -> 1
12344444 -> 5
112311 -> 2
888888 -> 6
135866667 -> 1