这个小游戏仅供于学习,切勿尝试赌博,勤劳努力才是正道,珍爱生命,远离赌博。
这个游戏就是用随机函数来的
#include <iostream>
#include<stdlib.h>
#include<time.h>
#define MAXTIMES 20
using namespace std;
double multiple;
double money;
double bet;
double add;
int times;
void betting();
int main() {
srand(time(NULL));
money=1000.0;
while(times<=MAXTIMES){
//TODO
cout<<"你的目前金额为"<<money<<endl;
cout<<"请输入你的注码金额(输入0 all in)"<<endl;
cin>>bet;
if(bet<=money){
if(bet==0){
bet=money;
}
betting();
cout<<"本次下注:"<<bet<<" 返回:"<<add<<" 目前剩余:"<<money<<endl;
}
else{
cout<<"注码不能能大于本金!!"<<endl;
}
cout<<"切勿尝试赌博,勤劳努力才是正道,珍爱生命,远离赌博。\n";
}
return 0;
}
void betting(){
money-=bet;
multiple=(double)(rand()%10+5)/10;
add=multiple*bet;
money+=add;
}