-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKarnaugh_Map.cpp
More file actions
166 lines (155 loc) · 2.51 KB
/
Karnaugh_Map.cpp
File metadata and controls
166 lines (155 loc) · 2.51 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#include <iostream>
#include "Karnaugh_Map.h"
using namespace std;
Karnaugh_Map::Karnaugh_Map(){}
bool Karnaugh_Map::numones(char a[], int size)
{
for(int i = 0; i < size;i++)
{
if(a[i] == '0')
{
SIZE3MAP[1][3] = '1';
}
else if(a[i] == '1')
{
SIZE3MAP[1][2] = '1';
}
else if(a[i] == '2')
{
SIZE3MAP[0][3] = '1';
}
else if(a[i] == '3')
{
SIZE3MAP[0][2] = '1';
}
else if(a[i] == '4')
{
SIZE3MAP[1][0] = '1';
}
else if(a[i] == '5')
{
SIZE3MAP[1][1] = '1';
}
else if(a[i] == '6')
{
SIZE3MAP[0][0] = '1';
}
else if(a[i] == '7')
{
SIZE3MAP[0][1] = '1';
}
else
{
return false; // If this array somehow holds something other than a 1 it return false
}
}
return true;
}
bool Karnaugh_Map::numds(char d[], int size)
{
for(int i = 0;i < size;i++)
{
if(d[i] == '0')
{
if(SIZE3MAP[1][3] == '1')
{
return false;
}
SIZE3MAP[1][3] = 'd';
}
else if(d[i] == '1')
{
SIZE3MAP[1][2] = 'd';
}
else if(d[i] == '2')
{
if(SIZE3MAP[0][3] == '1')
{
return false;
}
SIZE3MAP[0][3] = 'd';
}
else if(d[i] == '3')
{
if(SIZE3MAP[0][2] == '1')
{
return false;
}
SIZE3MAP[0][2] = 'd';
}
else if(d[i] == '4')
{
if(SIZE3MAP[1][0] == '1')
{
return false;
}
SIZE3MAP[1][0] = 'd';
}
else if(d[i] == '5')
{
if(d[i] == '1')
{
return false;
}
SIZE3MAP[1][1] = 'd';
}
else if(d[i] == '6')
{
if(SIZE3MAP[0][0] == '1')
{
return false;
}
SIZE3MAP[0][0] = 'd';
}
else if (d[i] == '7')
{
if(SIZE3MAP[0][1] == '1')
{
return false;
}
SIZE3MAP[0][1] = 'd';
}
else
{
return false; // If the array somehow manages to hold something other than a d it returns false
}
}
return true;
}
void Karnaugh_Map::display_map(int row, int column)
{
cout << "NOW DISPLAYING YOUR MAP\n\n";
if(row == 4 && column == 4)
{
for(int i = 0; i < row;i++)
{
for(int j = 0; j < column; j++)
{
cout << SIZE4_MAP[i][j] << "\t";
}
cout << endl;
}
}
else if(row == 2 && column == 4)
{
for(int i = 0; i < row;i++)
{
for(int j = 0; j < column; j++)
{
cout << SIZE3MAP[i][j] << "\t";
}
cout << endl;
}
}
else
{
for(int i = 0; i < row;i++)
{
for(int j = 0; j < column; j++)
{
cout << SIZE5_MAP[i][j] << "\t";
}
cout << endl;
}
}
}