fork download
  1. import java.lang.Math;
  2.  
  3. class ManipulacaoNumerica {
  4. public static int GerarC(String a, String b) {
  5. if (a == null || b == null) return -2; //inventei isso, não sei o que deveria fazer
  6. String c = "";
  7. int limite = Math.max(a.length(), b.length());
  8. for (int i = 0; i <= limite; i++) {
  9. if (i < a.length()) c += a.charAt(i);
  10. if (i < b.length()) c += b.charAt(i);
  11. }
  12. return c.length() > 6 ? -1 : Integer.valueOf(c.toString()); //tecnicamente não foi pedido bem isso
  13. }
  14.  
  15. public static void Executa(String a, String b) {
  16. System.out.println("Valores de Entrada: " + a + " - " + b);
  17. System.out.println("Valor de Saída: " + GerarC(a, b));
  18. }
  19.  
  20. public static void main(String[] args) {
  21. Executa("24", "1999");
  22. }
  23. }
  24.  
  25. //https://pt.stackoverflow.com/q/154373/101
Success #stdin #stdout 0.12s 36868KB
stdin
Standard input is empty
stdout
Valores de Entrada: 24 - 1999
Valor de Saída: 214999