Skip to content

Instantly share code, notes, and snippets.

@yunkai1841
Created May 7, 2021 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yunkai1841/2d3569277bd49550f52a1d2ce2c39855 to your computer and use it in GitHub Desktop.
Save yunkai1841/2d3569277bd49550f52a1d2ce2c39855 to your computer and use it in GitHub Desktop.
tern number to minterm and maxterm
#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