什么是c语言程序的真值表,真值表(C++)

您所在的位置:网站首页 逻辑运算的真值表是什么意思 什么是c语言程序的真值表,真值表(C++)

什么是c语言程序的真值表,真值表(C++)

#什么是c语言程序的真值表,真值表(C++)| 来源: 网络整理| 查看: 265

对于 真值表都不陌生。其原理略

代码如下:

#include

#include

void TruthTable(const int n);

enum { FALSE, TRUE };

int main()

{

const int nBoolNum = 5;

TruthTable(nBoolNum);

return 0;

}

void TruthTable(const int N)

{

int nState = (int)pow(2.0, N);

int nTotalNum = nState * N;

int* nPtr = new int[nTotalNum];

int nRem, nDiv, nCol;

int nCount = 0; // N incerments

for (int nIndex = 0; nIndex < nState; ++nIndex)

{

nDiv = nIndex;

for (nCol = N - 1 + nCount; nCol >= 0 + nCount; --nCol)

{

nRem = nDiv % 2;

nDiv /= 2;

if (!nRem)

nPtr[nCol] = FALSE;

else

nPtr[nCol] = TRUE;

}

for (int i = nCount; i < N + nCount; ++i) // Display

std::cout



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3