-
Notifications
You must be signed in to change notification settings - Fork 0
/
apaaja.c
63 lines (56 loc) · 1.45 KB
/
apaaja.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
int main(){
int t;
scanf("%d", &t);
int decrypting;
scanf("%d", &decrypting);
if (decrypting != 0 && decrypting != 1){
printf("Mode is not valid!");
return 0;
}
int key;
scanf("%d", &key);
char temp;
scanf("%c", &temp);
char M[1000];
scanf("%[^\n]", &M);
// printf("%d %d %d %s", t, encrypting, key, M);
key = fibo(key, 1, 1);
int Counter;
for (Counter = 0; Counter < strlen(M); Counter += 1){
char Letter;
Letter = M[Counter];
if (decrypting){
if(Letter >=97 || Letter <= 122){
Letter -= key%26;
if (Letter < 97){
Letter += 26;
}
}
else if(Letter >= 65 || Letter <= 90){
Letter -= key%26;
if (Letter < 65){
Letter += 26;
}
}
}
else{
if(Letter >=97 || Letter <= 122){
Letter += key%26;
if (Letter > 122){
Letter -= 26;
}
}
else if(Letter >= 65 || Letter <= 90){
Letter -= 65;
Letter += key%26;
Letter += 65;
if (Letter > 90){
Letter -= 26;
}
}
}
M[Counter] = Letter;
}
printf("%s", M);
return 0;
}