-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1024.c
46 lines (33 loc) · 863 Bytes
/
1024.c
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
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main() {
int N, inicioMetade;
char string[1001];
scanf("%i", &N);
getchar();
while(N > 0){
fgets(string, 1001, stdin);
int i = 0, j = strlen(string) - 1;
char aux;
for(i = 0; i < strlen(string) - 1; i++){ //passo 1
if(isalpha(string[i]))
string[i] += 3;
}
for(i = 0, j = strlen(string) - 2; i < j; i++, j--){ //passo 2
aux = string[i];
string[i] = string[j];
string[j] = aux;
}
if(strlen(string) % 2 == 0)
inicioMetade = strlen(string)/2 - 1;
else
inicioMetade = strlen(string)/2;
for(i = inicioMetade; i <= strlen(string) - 2; i++){ //passo 3
string[i] --;
}
fputs(string, stdout);
N--;
}
return 0;
}