fork(1) download
  1. class Teste {
  2.  
  3. public static int seuComparador(String a, String b) {
  4. String c = a;
  5. String d = b;
  6. while (c.length() < d.length()) c = "0" + c;
  7. while (c.length() > d.length()) d = "0" + d;
  8. return c.compareTo(d);
  9. }
  10.  
  11. public static void main(String[] args) {
  12. System.out.println(seuComparador("0", "3"));
  13. System.out.println(seuComparador("10", "3"));
  14. System.out.println(seuComparador("007", "300"));
  15. System.out.println(seuComparador("40", "040"));
  16. }
  17. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
-3
1
-3
0