-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCriptografia.java
More file actions
49 lines (33 loc) · 1.06 KB
/
Criptografia.java
File metadata and controls
49 lines (33 loc) · 1.06 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.util.Scanner;
public class Criptografia {
// 1024
public static void main(String[] args) {
Scanner leitor = new Scanner(System.in);
String texto = new String();
int cont;
char[] str;
cont = leitor.nextInt();
texto = leitor.nextLine();
while (cont > 0) {
texto = leitor.nextLine();
int aux = texto.length();
char[] straux = new char[aux];
str = texto.toCharArray();
for (int x = 0; x < aux; x++) {
if ((str[x] > 96 && str[x] < 123) || (str[x] > 64 && str[x] < 91)) {
str[x] = (char) (str[x] + 3);
}
}
for (int x = 0; x < straux.length; x++) {
aux--;
straux[x] = str[aux];
}
for (int x = straux.length / 2; x < straux.length; x++) {
straux[x] = (char) (straux[x] - 1);
}
cont--;
System.out.println(straux);
}
leitor.close();
}
}