fork 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 boolean isDescNumeric(String numOrStr)
  11. {
  12. int start = (int)(numOrStr.charAt(0) - '0');
  13. for (int i = 0; i < numOrStr.length(); i++)
  14. {
  15. int n = (int)(numOrStr.charAt(i) - '0');
  16. if (n != (start + i) % 10) return false;
  17. }
  18. return true;
  19. }
  20. public static void main (String[] args) throws java.lang.Exception
  21. {
  22. // your code goes here
  23. System.out.println(isDescNumeric("1234"));
  24. System.out.println(isDescNumeric("8901"));
  25. System.out.println(isDescNumeric("1345"));
  26. }
  27. }
Success #stdin #stdout 0.1s 320320KB
stdin
Standard input is empty
stdout
true
true
false