import java.lang.Math;
class ManipulacaoNumerica {
if (a == null || b == null) {
return -2; //inventei isso, não sei o que deveria fazer
}
int limite
= Math.
max(a.
length(), b.
length()); for (int i = 0; i <= limite; i++) {
if (i < a.length()) {
c += a.charAt(i);
}
if (i < b.length()) {
c += b.charAt(i);
}
}
return c.
length() > 6 ? -1 : Integer.
valueOf(c.
toString()); //tecnicamente não foi pedido bem isso }
System.
out.
println("Valores de Entrada: " + a
+ " - " + b
); System.
out.
println("Valor de Saída: " + GerarC
(a, b
)); }
public static void main
(String[] args
) { Executa("24", "1999");
}
}
aW1wb3J0IGphdmEubGFuZy5NYXRoOwoKY2xhc3MgTWFuaXB1bGFjYW9OdW1lcmljYSB7CglwdWJsaWMgc3RhdGljIGludCBHZXJhckMoU3RyaW5nIGEsIFN0cmluZyBiKSB7CgkgICAgaWYgKGEgPT0gbnVsbCB8fCBiID09IG51bGwpIHsKCSAgICAJcmV0dXJuIC0yOyAvL2ludmVudGVpIGlzc28sIG7Do28gc2VpIG8gcXVlIGRldmVyaWEgZmF6ZXIKCSAgICB9CiAgICAgICAgU3RyaW5nIGMgPSAiIjsKICAgICAgICBpbnQgbGltaXRlID0gTWF0aC5tYXgoYS5sZW5ndGgoKSwgYi5sZW5ndGgoKSk7CiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPD0gbGltaXRlOyBpKyspIHsKICAgICAgICAJaWYgKGkgPCBhLmxlbmd0aCgpKSB7CiAgICAJICAgIAljICs9IGEuY2hhckF0KGkpOwogICAgICAgIAl9CiAgICAgICAgCWlmIChpIDwgYi5sZW5ndGgoKSkgewogICAgCSAgICAJYyArPSBiLmNoYXJBdChpKTsKICAgICAgICAJfQogICAgICAgIH0KICAgICAgIAlyZXR1cm4gYy5sZW5ndGgoKSA+IDYgPyAtMSA6IEludGVnZXIudmFsdWVPZihjLnRvU3RyaW5nKCkpOyAvL3RlY25pY2FtZW50ZSBuw6NvIGZvaSBwZWRpZG8gYmVtIGlzc28KCX0KCglwdWJsaWM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