AcWing
  • 首页
  • 课程
  • 题库
  • 更多
    • 竞赛
    • 题解
    • 分享
    • 问答
    • 应用
    • 校园
  • 关闭
    历史记录
    清除记录
    猜你想搜
    AcWing热点
  • App
  • 登录/注册

nand 开始做门

作者: 作者的头像   爱Coding的鸠 ,  2025-05-06 22:27:42 · 天津 ,  所有人可见 ,  阅读 4


0


#include<bits/stdc++.h>
using namespace std;
bool NAND(bool a,bool b){
    return not(a and b);
    /*
    0 0
    0 1
    1 0
    1 1

    1
    1
    1
    0
    */
}
bool NOT(bool a){
    return NAND(a,a);
    /*
    0
    1

    1
    0
    */
}
bool AND(bool a,bool b){
    return NOT(NAND(a,b));
    /*
    0 0
    0 1
    1 0
    1 1

    0
    0
    0
    1
    */
}
bool OR(bool a,bool b){
    return NOT(AND(NOT(a),NOT(b)));
    /*
    0 0
    0 1
    1 0
    1 1

    0
    1
    1
    1
    */
}
bool TRue(bool a){
    return OR(NOT(a),a);
    /*
    0
    1

    1
    1
    */
}
bool FAlse(bool a){
    return AND(NOT(a),a);
    /*
    0
    1

    0
    0
    */
}
bool NOR(bool a,bool b){
    return AND(NOT(a),NOT(b));
    /*
    0 0
    0 1
    1 0
    1 1

    1
    0
    0
    0
    */
}
bool XOR(bool a,bool b){
    return OR(AND(NOT(a),b),AND(a,NOT(b))); 
    /*
    0 0
    0 1
    1 0
    1 1

    0
    1
    1
    0
    */
}
int main(){
    bool a,b;
    while(cin >> a >> b)
        cout << XOR(a,b) << endl;
}

借鉴图灵完备

0 评论

App 内打开
你确定删除吗?
1024
x

© 2018-2025 AcWing 版权所有  |  京ICP备2021015969号-2
用户协议  |  隐私政策  |  常见问题  |  联系我们
AcWing
请输入登录信息
更多登录方式: 微信图标 qq图标 qq图标
请输入绑定的邮箱地址
请输入注册信息