用编程解决 公务员考试 中的逻辑推理题
三、完整代码
var result = [];
for (var wang = 0; wang <= 1; wang++) {
for (var zhang = 0; zhang <= 1; zhang++) {
for (var li = 0; li <= 1; li++) {
var condition_1 = (wang && zhang) || (!wang);
var condition_2 = (li && !wang) || (!li);
var condition_3 = (zhang && li) || (!zhang);
var condition_4 = !(wang && li);
if (condition_1 && condition_2 && condition_3 && condition_4) {
var re = "wang:" + wang + ",zhang:" + zhang + ",li:" + li;
result.push(re);
}
}
}
}
console.log(result);