-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCripto.c
More file actions
63 lines (53 loc) · 1.87 KB
/
Cripto.c
File metadata and controls
63 lines (53 loc) · 1.87 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
void Cripto(char *txt1, char *controle1, char *controle2)
{
int Tam, Tamc, x = 0, i = 0;
Tam = strlen(txt1);
Tamc = strlen(controle1);
for (x = 0; x < Tam; x++)
{
for (i = 0; i < Tamc; i++)
{
if (*(txt1 + x) == controle1[i] && ((*(txt1 + x) > 64 && *(txt1 + x) < 91) || (*(txt1 + x) > 96 && *(txt1 + x) < 123)))
*(txt1 + x) = controle2[i];
else if (*(txt1 + x) == controle2[i] && ((*(txt1 + x) > 64 && *(txt1 + x) < 91) || (*(txt1 + x) > 96 && *(txt1 + x) < 123)))
*(txt1 + x) = controle1[i];
else if (*(txt1 + x) == tolower(controle1[i]) && ((*(txt1 + x) > 64 && *(txt1 + x) < 91) || (*(txt1 + x) > 96 && *(txt1 + x) < 123)))
*(txt1 + x) = tolower(controle2[i]);
else if (*(txt1 + x) == tolower(controle2[i]) && ((*(txt1 + x) > 64 && *(txt1 + x) < 91) || (*(txt1 + x) > 96 && *(txt1 + x) < 123)))
*(txt1 + x) = tolower(controle1[i]);
else if (*(txt1 + x) == controle1[i])
*(txt1 + x) = tolower(controle2[i]);
else if (*(txt1 + x) == controle2[i])
*(txt1 + x) = tolower(controle1[i]);
}
}
*(txt1 + x) = '\0';
}
int main()
{
char texto[1000], controle1[22], controle2[22];
int x, y, j;
while (scanf("%i%i", &x, &y) != EOF)
{
for (j = 0; j <= x; j++)
scanf("%c", &controle1[j]);
controle1[j] = '\0';
for (j = 0; j <= x; j++)
scanf("%c", &controle2[j]);
controle1[j] = '\0';
for (x = 0; x < y; x++)
{
getchar();
scanf("%[^\n]", texto);
Cripto(texto, controle1, controle2);
printf("%s\n", texto);
texto[0] = '\0';
}
printf("\n");
}
return 0;
}