📄 q-m.h
字号:
typedef enum {complemented, uncomplemented, doesntappear}TRIT;
typedef TRIT[16] CUBE; // Represent a single product term weth up to 16 variables
# define MAX_VARS 16 // Max # of variables in a product term
typedef unsigned short WORD; // Use 16-bit words
struct cube
{
WORD t; // Bits 1 for uncomplemented variables.
WORD f; // Bits 1 for complemented variables.
};
typedef struct cube CUBE;
CUBE P1, P2, P3; // Allocate three cubes for use by program.
int EqualCubes(CUBE C1, CUBE C2)// Returns true if C1 and C2 are identical.
{
return ( (C1.t == C2.t) && (C1.f == C2.f) );
}
int Oneone(WORD w) // Returns true if w has exactly one 1 bit.
{
// Optimizing the speed of this routine is critical
// and is left as an exercise for the hacker.
int ones = 0;
for (int b=0; b<MAX_VARS; b++)
{
if (w & 1)
{
ones++;
}
w = w>>1;
}
return ((ones==1));
}
int Combinable(CUBE C1, CUBE C2)
{
// Returns true if C1 and C2 differ in only one variable,
// which appears true in one and false in the other.
WORD twordt, twordf;
twordt = C1.t ^ C2.t;
twordf = C1.f ^ C2.f;
return ( (twordt==twordf) && (Oneone(twordt)) );
}
void Combine(CUBE C1, CUBE C2, CUBE *C3)
{
//Combines C1 and C2 using theorem T10, and stores the
// result in C3. Assumes Combinable(C1, C2) is true.
C3->t = C1.t & C2.t;
C3->f = C1.f & C2.f;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -