-
Notifications
You must be signed in to change notification settings - Fork 191
Expand file tree
/
Copy pathFakeCypher.java
More file actions
25 lines (21 loc) · 834 Bytes
/
Copy pathFakeCypher.java
File metadata and controls
25 lines (21 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import java.lang.Math;
class ManipulacaoNumerica {
public static int GerarC(String a, String b) {
if (a == null || b == null) return -2; //inventei isso, não sei o que deveria fazer
String c = "";
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
}
public static void Executa(String a, String b) {
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");
}
}
//https://pt.stackoverflow.com/q/154373/101