-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource code.cpp
More file actions
69 lines (59 loc) · 1.19 KB
/
Source code.cpp
File metadata and controls
69 lines (59 loc) · 1.19 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
#include <iostream>
#include <string>
#include <stack>
using namespace std;
void main()
{
unsigned int A[5535]; // Array of minterms.
unsigned int B[5535]; // Array of no of bits.
string C[5535];
stack <int> s;
for (int i = 0; i < 327; i++)
{
A[i] = 0;
B[i] = 0;
C[i] = "";
}
cout << "input the minterm including dont cares and enter -1 to signal the ending of the minterms" << endl;
int i = 0;
while (true){
cout << "input the minterm including dont cares and enter -1 to signal the ending of the minterms" << endl;
cin >> i;
if (i == -1){
break;
}
else
A[i] = 1;
}
for (int j = 0; j < 327; j++){
if (A[j] == 1){
int instWord2 = j;
int total = 0;
int count = 0;
while (instWord2>0)
{
total = instWord2 % 2;
if (total == 1)
count++;
instWord2 /= 2;
s.push(total);
}
while (!s.empty())
{
int x = s.top();
C[j] = C[j] + "" + to_string(x);
s.pop();
}
while (C[j].size() <16){
C[j] = "0" + C[j];
}
B[j] = count;
}
}
for (int i = 0; i < 10; i++){
if (A[i] == 1){
cout << C[i] << endl;
}
}
system("pause");
}