本人依靠书籍,写了一个很简单的“读心术程序”,有需要的可以参考(用的是if和else)

#include <bits/stdc++.h>
using namespace std;
int main() {
    char a;
    int b=0;
    cout<<"1-63之间想一个数字"<<endl;
    cout<<" 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61"<<endl;
    cout<<"这些数字中有你想的数字吗 a.yes   b.no"<<endl;
    cin>>a;
    if(b<=0&&b>63) {
        cout<<"您已违反游戏规则"<<endl;
    }
    if(a=='a') {
        b=b+1;
        cout<<" 2 3 6 7 10 11 14 15 18 19 22 23 26 27 30 31 34 35 38 39 42 43 46 47 50 51 54 55 58 59 62 63"<<endl;
        cout<<"这些数字中有你想的数字吗 a.yes   b.no"<<endl;
    } else if(a=='b') {
        cout<<" 2 3 6 7 10 11 14 15 18 19 22 23 26 27 30 31 34 35 38 39 42 43 46 47 50 51 54 55     58 59 62 63"<<endl;            
        cout<<"这些数字中有你想的数字吗 a.yes   b.no"<<endl;
    }
    cin>>a;
    if(a=='a') {
        b=b+2;
        cout<<" 4 5 6 7 12 13 14 15 20 21 22 23 28 29 30 31 36 37 38 39 44 45 46 47 52 53 54 55 60 61 62 63"<<endl;
        cout<<"这些数字中有你想的数字吗 a.yes   b.no"<<endl;
    } else if(a=='b') {
        cout<<" 4 5 6 7 12 13 14 15 20 21 22 23 28 29 30 31 36 37 38 39 44 45 46 47 52 53 54 55 60 61 62 63"<<endl;
        cout<<"这些数字中有你想的数字吗 a.yes   b.no"<<endl;
    }
    cin>>a;
    if(a=='a') {
        b=b+4;
        cout<<" 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31 40 41 42 43 44 45 46 47 56 57 58 59 60 61 62 63"<<endl;
        cout<<"这些数字中有你想的数字吗 a.yes   b.no"<<endl;
    } else if(a=='b') {
        cout<<" 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31 40 41 42 43 44 45 46 47 56 57 58 59 60 61 62 63"<<endl;
        cout<<"这些数字中有你想的数字吗 a.yes   b.no"<<endl;
    }
    cin>>a;
    if(a=='a') {
        b=b+8;
        cout<<" 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63"<<endl;
        cout<<"这些数字中有你想的数字吗 a.yes   b.no"<<endl;
    } else if(a=='b') {
        cout<<" 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63"<<endl;
        cout<<"这些数字中有你想的数字吗 a.yes   b.no"<<endl;
    }
    cin>>a;
    if(a=='a') {
        b=b+16;
        cout<<" 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63"<<endl;
        cout<<"这些数字中有你想的数字吗 a.yes   b.no"<<endl;
    } else if(a=='b') {
        cout<<" 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63"<<endl;
        cout<<"这些数字中有你想的数字吗 a.yes   b.no"<<endl;
    }
    cin>>a;
    
    if(a=='a') {
        b=b+32;
    }
    
    cout<<"你想的数字是:"<<b;
    return 0;
}

  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值