-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patha.c
More file actions
76 lines (67 loc) · 1.92 KB
/
a.c
File metadata and controls
76 lines (67 loc) · 1.92 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
#include <stdio.h>
#include <math.h>
#include <string.h>
int main() {
int nv, no;
int v[10][10], o[10][10];
int rows;
printf("Enter number of variables of input: ");
scanf("%d", &nv);
printf("Enter number of variables of output: ");
scanf("%d", &no);
rows = pow(2, nv);
printf("Enter input variables in rg format (each column for a variable, %d rows):\n", rows);
for (int i = 0; i < nv; i++) {
printf("Enter values for variable %d:\n", i + 1);
for (int j = 0; j < rows; j++) {
scanf("%d", &v[j][i]);
}
}
printf("Enter output in rg format (each column for an output, %d rows):\n", rows);
for (int i = 0; i < no; i++) {
printf("Enter values for output %d:\n", i + 1);
for (int j = 0; j < rows; j++) {
scanf("%d", &o[j][i]);
}
}
// Example: print the input and output tables
printf("\nInput Table:\n");
for (int j = 0; j < rows; j++) {
for (int i = 0; i < nv; i++) {
printf("%d ", v[j][i]);
}
printf("\n");
}
printf("\nOutput Table:\n");
for (int j = 0; j < rows; j++) {
for (int i = 0; i < no; i++) {
printf("%d ", o[j][i]);
}
printf("\n");
}
char e[50];
int in = 0;
for (int i = 0; i < rows; i++) {
char c = 'A';
for (int j = 0; j < no; j++) {
if (o[i][j] == 1) {
for (int k = 0; k < nv; k++) {
if (v[i][k] == 0) {
e[in++] = c;
c++;
e[in++] = "'";
} else if (v[i][k] == 1) {
e[in++] = c;
c++;
}
if (i + 1 < rows) {
e[in++] = '+';
}
}
}
}
}
e[in] = '\0';
printf("%s", e);
return 0;
}