/*---------------------------------------------------------------------------------------------------
Author:我逍遥
1、三个骰子随机产生,系统每隔2秒自动产生。
2、三个骰子之和大于12,押大赢;小于等于10,押小赢;等于11,庄赢。(豹子除外,豹子全收翻三倍)
3、每隔10轮,游戏自动暂停,提示休息。
4、休息完成之后,按任意键清屏,继续游戏。
---------------------------------------------------------------------------------------------------*/
#include<iostream>
#include<Windows.h>
#include<ctime>
using namespace std;
int gameCount;
int n1, n2, n3, sum;
int main()
{
cout << " 掷骰子游戏开始!" << endl;
srand(time(NULL));
while (true)
{
cout << "第"<<++gameCount<<"轮骰子开始掷!" << endl;
Sleep(2000);
n1 = 1 + rand() % 6;
n2 = 1 + rand() % 6;
n3 = 1 + rand() % 6;
sum = n1 + n2 + n3;
cout << " "<<n1<<" "<<n2<<" "<<n3 << " ";
if ((n1 == n2) && (n2 == n3)){
cout << " 豹子赢,赌注翻3倍!!!" << endl;
}
else
{
if (sum >= 12){
cout << " 压 大 赢" << endl;
}
if (sum <= 10){
cout << " 压 小 赢" << endl;
}
if (sum == 11){
cout << " 庄 家 全 收" << endl;
}
}
if (gameCount%10 == 0){
system("cls");
cout << "已经玩了"<<gameCount/10*10<<"局了,休息一会再继续战斗!" << endl;
cout << " 休息完毕之后,";
system("pause");
system("cls");
}
}
return 0;
}
C++掷骰子游戏
最新推荐文章于 2025-03-30 15:20:14 发布