class="markdown_views prism-atom-one-light">
应付期末考试用的…按顺序输进去六位数字,自动生成Markdown格式的每个JK触发器的卡诺图。
生成Excel可以直接打开的csv表格。
#include
using namespace std;
char f[8],c=',';
int a[6];
int main()
{
for(int i=0; i<6; ++i)cin>>a[i];
ofstream cout("KarnaughMap.csv");
cout<<"NextMap
"<"State"
<"$Q_2$"<"$Q_1$"<"$Q_0$"<"
"
<"-"<"
";
for(int i=0; i<6; ++i)
{
cout<for(int x=2; ~x; --x)cout<1)%6]>>x&1);
cout<"
";
}
for(int x=2; ~x; --x)
for(int j=1; ~j; --j)
{
fill(f,f+8,'X');
for(int i=0; i<6; ++i)
if(j!=(a[i]>>x&1))
f[a[i]]='0'+(j==(a[(i+1)%6]>>x&1));
cout<<(j?"$J_":"$K_")<"$Map
"<"$Q_0\setminus Q_1Q_2$"
<"00"<"01"<"11"<"10"<"
"
<"-"<"
"
<"0"<0]<4]<6]<2]<"
"
<"1"<1]<5]<7]<3]<"
";
}
}
生成Markdown格式,然后就可以直接导进CSDN里了。
#include
using namespace std;
char f[8],c='|';
int a[6];
int main()
{
for(int i=0; i<6; ++i)cin>>a[i];
ofstream cout("KarnaughMap.md");
cout<<"NextMap
"<"State"
<"$Q_2$"<"$Q_1$"<"$Q_0$"<"
"
<"-"<"
";
for(int i=0; i<6; ++i)
{
cout<for(int x=2; ~x; --x)cout<1)%6]>>x&1);
cout<"
";
}
for(int x=2; ~x; --x)
for(int j=1; ~j; --j)
{
fill(f,f+8,'X');
for(int i=0; i<6; ++i)
if(j!=(a[i]>>x&1))
f[a[i]]='0'+(j==(a[(i+1)%6]>>x&1));
cout<<(j?"$J_":"$K_")<"$Map
"<"$Q_0\setminus Q_1Q_2$"
<"00"<"01"<"11"<"10"<"
"
<"-"<"
"
<"0"<0]<4]<6]<2]<"
"
<"1"<1]<5]<7]<3]<"
";
}
}