随机数——彩票

#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b,qian = 50;
    while(qian>0){
        srand(time(0));
        b = rand()%9+1;
        cout<<"请输入你选的号码?";
        cin>>a;
        if(a==b){
            qian+=90;
            cout<<"恭喜你!!!中奖了!!!奖励100元"<<"当前余额:"<<qian<<endl;
        }else{
            qian-=10;
            cout<<"没中奖,扣除10元,中奖号码是:"<<b<<endl<<"当前余额:"<<qian<<endl;
        }
    }
    cout<<"破产了!!!";
    return 0;
}

 

posted @ 2023-05-13 19:41  王一行(小号)  阅读(31)  评论(0编辑  收藏  举报