-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdecodeit.c
More file actions
119 lines (115 loc) · 3.28 KB
/
decodeit.c
File metadata and controls
119 lines (115 loc) · 3.28 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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// author:Hemant1101
// lang: C
// topic: codechef problem ( file name is the problem code )
#include <stdio.h>
#include <string.h>
int main()
{
int t;
scanf("%d", &t);
while (t--)
{
int n, x, y = 4, i, m = 0;
scanf("%d", &n);
x = n / 4;
int g = x;
char s[n], f[y], a[g];
scanf("%s", s);
while (x--)
{
for (i = m; i < m + 4; i++)
{
f[i - m] = s[i];
}
if (f[0] == '0' && f[1] == '0' && f[2] == '0' && f[3] == '0')
{
a[x] = 'a';
// printf("a");
}
if (f[0] == '0' && f[1] == '0' && f[2] == '0' && f[3] == '1')
{
a[x] = 'b';
}
// printf("b");
if (f[0] == '0' && f[1] == '0' && f[2] == '1' && f[3] == '0')
{
a[x] = 'c';
}
// printf("c");
if (f[0] == '0' && f[1] == '0' && f[2] == '1' && f[3] == '1')
{
a[x] = 'd';
}
// printf("d");
if (f[0] == '0' && f[1] == '1' && f[2] == '0' && f[3] == '0')
{
a[x] = 'e';
}
// printf("e");
if (f[0] == '0' && f[1] == '1' && f[2] == '0' && f[3] == '1')
{
a[x] = 'f';
}
// printf("f");
if (f[0] == '0' && f[1] == '1' && f[2] == '1' && f[3] == '0')
{
a[x] = 'g';
}
// printf("g");
if (f[0] == '0' && f[1] == '1' && f[2] == '1' && f[3] == '1')
{
a[x] = 'h';
}
// printf("h");
if (f[0] == '1' && f[1] == '0' && f[2] == '0' && f[3] == '0')
{
a[x] = 'i';
}
// printf("i");
if (f[0] == '1' && f[1] == '0' && f[2] == '0' && f[3] == '1')
{
a[x] = 'j';
}
// printf("j");
if (f[0] == '1' && f[1] == '0' && f[2] == '1' && f[3] == '0')
{
a[x] = 'k';
}
// printf("k");
if (f[0] == '1' && f[1] == '0' && f[2] == '1' && f[3] == '1')
{
a[x] = 'l';
}
// printf("l");
if (f[0] == '1' && f[1] == '1' && f[2] == '0' && f[3] == '0')
{
a[x] = 'm';
}
// printf("m");
if (f[0] == '1' && f[1] == '1' && f[2] == '0' && f[3] == '1')
{
a[x] = 'n';
}
// printf("n");
if (f[0] == '1' && f[1] == '1' && f[2] == '1' && f[3] == '0')
{
a[x] = 'o';
}
// printf("o");
if (f[0] == '1' && f[1] == '1' && f[2] == '1' && f[3] == '1')
{
a[x] = 'p';
}
// printf("p");
m = i;
}
// strrev(a);
// printf("%s", a);
for (int l = g - 1; l >= 0; l--)
{
printf("%c", a[l]);
}
printf("\n");
}
return 0;
}