forked from COLTEC-DAW/E05-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
alta-ordem.js
104 lines (102 loc) · 2.52 KB
/
alta-ordem.js
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
function ordenacao(vetor) {
for(let i = 0; i < vetor.length; i++) {
for(let j = i + 1; j < vetor.length; j++) {
if (vetor[i] > vetor[j]) {
let aux = vetor[i];
vetor[i] = vetor[j];
vetor[j] = aux;
}
}
}
return vetor
}
function cifraDeCesar(str) {
var re = /[\W_]/g;
str = str.toUpperCase().replace(re, '');
for(let i = 0; i < str.length; i++) {
switch(str[i]) {
case 'A':
str[i] = 'D';
break;
case 'B':
str[i] = 'E';
break;
case 'C':
str[i] = 'F';
break;
case 'D':
str[i] = 'G';
break;
case 'E':
str[i] = 'H';
break;
case 'F':
str[i] = 'I';
break;
case 'G':
str[i] = 'J';
break;
case 'H':
str[i] = 'K';
break;
case 'I':
str[i] = 'L';
break;
case 'J':
str[i] = 'M';
break;
case 'K':
str[i] = 'N';
break;
case 'L':
str[i] = 'O';
break;
case 'M':
str[i] = 'P';
break;
case 'N':
str[i] = 'Q';
break;
case 'O':
str[i] = 'R';
break;
case 'P':
str[i] = 'S';
break;
case 'Q':
str[i] = 'T';
break;
case 'R':
str[i] = 'U';
break;
case 'S':
str[i] = 'V';
break;
case 'T':
str[i] = 'W';
break;
case 'U':
str[i] = 'X';
break;
case 'V':
str[i] = 'Y';
break;
case 'W':
str[i] = 'Z';
break;
case 'X':
str[i] = 'A';
break;
case 'Y':
str[i] = 'B';
break;
case 'Z':
str[i] = 'C';
break;
default:
console.log("Letra nao encontrada");
}
}
}
console.log(ordenacao([5, 6, 8, 0, 2]));
console.log(cifraDeCesar("cifra"));