Created
May 7, 2021 15:45
-
-
Save yunkai1841/2d3569277bd49550f52a1d2ce2c39855 to your computer and use it in GitHub Desktop.
tern number to minterm and maxterm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<vector> | |
#include<algorithm> | |
using namespace std; | |
int main(){ | |
vector<int> v; | |
cout << "bit>"; | |
int bit; | |
cin >> bit; | |
int input; | |
while (cin >> input) | |
{ | |
v.push_back(input); | |
} | |
for (auto &&i : v) | |
{ | |
cout << "m_{" << i << "}+"; | |
} | |
cout << "\b\b"; | |
cout << endl; | |
int length=1; | |
for (int i = 0; i < bit; i++) | |
{ | |
length *= 2; | |
} | |
for (int i = 0; i < length; i++) | |
{ | |
if(find(v.begin(), v.end(), i) == v.end()){ | |
cout << "M_{" << i << "}"; | |
} | |
} | |
cout << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment