-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathcoding_decoding
45 lines (42 loc) · 1021 Bytes
/
coding_decoding
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
#include <stdio.h>
#include <stdlib.h>
int main()
{
char para[2000000];
printf("Enter a string-");
scanf("%[^\n]",¶); //scanning the whole string, including the white spaces
printf("%s\n",para);
int before,after;
char alphabet[]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char number[]={'0','1','2','3','4','5','6','7','8','9'};
for(int i=0;i<2000000;i++)
{
for(int j=0;j<26;j++)
{
before=j+13;
after=j-13;
if(para[i]==alphabet[j])
{
if(j<13)
para[i]=alphabet[before];
else
para[i]=alphabet[after];
break;
}
}
for(int j=0;j<10;j++)
{
before=j+5;
after=j-5;
if(para[i]==number[j])
{
if(j<5)
para[i]=number[before];
else
para[i]=number[after];
break;
}
}
}printf("%s",para);
return 0;
}