-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfory.c
76 lines (74 loc) · 1.59 KB
/
fory.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
64
65
66
67
68
69
70
71
72
73
74
75
76
int rule_application(int left, int center, int right, int *res) {
if (left == 1) {
if (center == 1) {
if (right == 1) {
return 0;
} else {
return 1;
}
} else {
if (right == 1) {
return 1;
} else {
return 0;
}
}
} else {
if (center == 1) {
if (right == 1) {
return 1;
} else {
return 1;
}
} else {
if (right == 1) {
return 1;
} else {
return 0;
}
}
}
return -1;
}
char oneorzero(int input) {
if (input == 1) {
return '1';
} else {
return '0';
}
return 'e';
}
int main() {
int res;
int i;
int j;
int k;
int idx;
int jdx;
int kdx;
char print;
char left;
char center;
char right;
for (i = 0; i < 2; i = i + 1) {
idx = i - 1;
for (j = 0; j < 2; j = j + 1) {
jdx = j - 1;
for (k = 0; k < 2; k = k + 1) {
kdx = k - 1;
res = rule_application(idx, jdx, kdx);
print = oneorzero(res);
left = oneorzero(idx);
center = oneorzero(jdx);
right = oneorzero(kdx);
putchar(left);
putchar(center);
putchar(right);
putchar(':');
putchar(print);
putchar(10);
}
}
}
return 0;
}