赌博
#include <bits/stdc++.h> #include <windows.h> #define huang return #define da 0 #define shan ; #define Min 10 using namespace std; int a[11][11], a2[11], a3[101][3], b[5][6],s=0; int qwe=0; int main() { b[0][0] = 100000, b[0][1] = 10000, b[0][2] = 5000, b[0][3] = 2500, b[0][4] = 2000; b[0][5] = 1500, b[0][6] = 1500, b[1][1] = 15000, b[1][2] = 2000, b[1][3] = 800; b[1][4] = 800, b[1][5] = 1000, b[2][2] = 1000, b[2][3] = 700, b[2][4] = 200; b[2][5] = 400, b[3][3] = 300, b[3][4] = 0, b[4][4] = 800; string op; int money = 1000000, Max = money; cout << "你有" << money << "元资产,快去买彩票赚钱吧!\n\n"; while (1) { if (money < Min) { cout << "你把家底败光了!\n\n"; break; } cout << "彩票广场:\n\n"; cout << "巨佬AKIOI(1)\n"; cout << "宝石闪耀(2)\n"; cout << "足球竞猜(3)\n"; cout << "退出(E)\n" ; cout << "敬请期待……\n\n"; while (cin >> op) { if (op == "1" || op == "2" || op == "3" || op == "E") { break; } else { cout << "没有此选项……\n"; } } if (op == "E") { break; } if (op == "1") { cout << "欢迎来到“巨佬AKIOI”刮刮乐商店。\n"; cout << "游戏规则:共有10行,第i行有10-i+1个中奖号码,右方会有倍数Ai。第12行有两个以空格隔开的号码,分别是巨佬号码和AK号码。当第i行出现巨佬号码时,则获得2*i元奖金;当第j行出现AK号码时,则获得2*j*Aj元奖金。\n"; cout << "是否购买?(Y/N)\n"; while (cin >> op) { if (op == "Y" || op == "N") { break; } else { cout << "我没明白你的意思……\n"; } } if (op == "N") { continue; } else { cout<<"请选择购买金额\n"; cin>>s; if (money < s) { cout << "你的资产不足,无法购买此彩票。\n\n"; continue; } else { money -= s; cout << "已购买,花费 "<<s<<" 元,剩余"; cout << money; cout << "元。\n"; cout << "刮开!(任意键)\n"; cin >> op; int x, y, tot = 0, sum = 0; srand(rand()*114514+time(0)*1919810-10086); x = rand() % 99 + 1; srand(rand()*114514+time(0)*1919810-10086); y = rand() % 99 + 1; for (int i = 1; i <= 10; ++i) { for (int j = 1; j <= 10 - i + 1; ++j) { srand(rand()*114514+time(0)*1919810-10086); a[i][j] = rand() % 99 + 1; cout << a[i][j] / 10 << a[i][j] % 10 << ' '; } srand(rand()*114514+time(0)*1919810-10086); a2[i] = rand() % 10 + 1; cout << ' ' << a2[i] << 'x' << endl; } cout << endl << x / 10 << x % 10 << ' ' << y / 10 << y % 10 << endl << endl; Sleep(2000); for (int i = 1; i <= 10; ++i) { for (int j = 1; j <= 10 - i + 1; ++j) { if (a[i][j] == x || a[i][j] == y) { a3[++tot][0] = i, a3[tot][1] = j; if (a[i][j] == x) { a3[tot][2] = i * 2; } else { a3[tot][2] = i * 2 * a2[i]; } } } } for (int i = 1; i <= tot; ++i) { cout << "第" << a3[i][0] << "行第" << a3[i][1] << "个号码:中奖" << a3[i][2]*s*0.1 << "元!\n"; sum += a3[i][2]*s*0.1; Sleep(500); } Sleep(1500); if (sum == 0) { cout << "很遗憾,未中奖……\n"; } else { cout << endl; money += sum; cout << "恭喜你,中奖" << sum << "元!\n"; cout << "剩余资产:" << money << "元。" << endl << endl; } } } } else if (op == "2") { cout << "欢迎来到“宝石闪耀”刮刮乐商店。\n"; cout << "游戏规则:共3行,每行4各中奖号码,号码是蓝、红和黄三种宝石的其中一种。当三种宝石的数量按升序排序后分别是x,y和z是,获得对应奖金。\n"; cout << "以下是对应奖金:\n"; cout << " x y z 奖金\n"; cout << " 3 4 5 0 \n"; cout << " 2 4 6 200 \n"; cout << " 3 3 6 300 \n"; cout << " 2 5 5 400 \n"; cout << " 2 3 7 700 \n"; cout << " 4 4 4 800 \n"; cout << " 1 3 8 800 \n"; cout << " 1 4 7 800 \n"; cout << " 1 5 6 1000 \n"; cout << " 2 2 8 1000 \n"; cout << " 0 5 7 1500 \n"; cout << " 0 6 6 1500 \n"; cout << " 0 4 8 2000 \n"; cout << " 1 2 9 2000 \n"; cout << " 0 3 9 2500 \n"; cout << " 0 2 10 5000 \n"; cout << " 0 1 11 10000 \n"; cout << " 1 1 10 15000 \n"; cout << " 0 0 12 100000\n"; cout << "购买价格:500元。\n"; cout << "是否购买?(Y/N)\n"; while (cin >> op) { if (op == "Y" || op == "N") { break; } else { cout << "我没明白你的意思……\n"; } } if (op == "N") { continue; } else { if (money < 500) { cout << "你的资产不足,无法购买此彩票。\n"; continue; } else { money -= 500; cout << "已购买,花费500元,剩余"; cout << money; cout << "元。\n"; cout << "刮开!(任意键)\n"; cin >> op; int x = 0, y = 0, z = 0, t; for (int i = 1; i <= 3; ++i) { for (int j = 1; j <= 4; ++j) { srand(rand()*114514+time(0)*1919810-10086); int att = rand() % 3; if (att == 0) { cout << "红 "; x++; } else if (att == 1) { cout << "黄 "; y++; } else { cout << "蓝 "; z++; } } cout << endl; } cout << endl; int xx = min(min(x, y), z), zz = max(max(x, y), z), yy = x + y + z - xx - zz; t = b[xx][yy]; money += t; Sleep(2000); cout << "你中了" << xx << ' ' << yy << ' ' << zz << "号奖,获得奖金" << t << "元,剩余资产" << money << "元。\n\n"; } } } else if (op == "3") { cout << "欢迎来到“足球竞猜”下注页面。\n"; cout << "游戏规则:红、蓝两支球队进行足球比赛,你可以选择一支球队进行下注。当下注方胜时,会双倍返还;当双方打平时,仅单倍返还;当下注方败时,则不返还。\n"; cout << "下注金额下限:20元。\n"; cout << "是否下注?(Y/N)\n"; while (cin >> op) { if (op == "Y" || op == "N") { break; } else { cout << "我没明白你的意思……\n"; } } if (op == "N") { continue; } else { cout << "请说出你要下注的球队:(B/R)\n"; while (cin >> op) { if (op == "B" || op == "R") { break; } else { cout << "没有这支球队。\n"; } } int x; if (op == "B") { x = 0; } else { x = 1; } int cost; cout<<"请选择下注倍数:(扣除相应倍数的钱)\n"; cin>>qwe; cout << "请说出你要下注的金额:\n"; while (cin >> cost) { if (cost < 20) { cout << "下注金额过低,至少要下注20元。\n"; } else if (cost*qwe > money) { cout << "你的资产不足,无法下注。\n"; } else { break; } } money -= cost; cout << "下注成功,剩余资产" << money << "元。\n"; cout << "比赛开始!\n"; int xx = 0, yy = 0; for (int i = 1; i <= 90; ++i) { srand(rand()*114514+time(0)*1919810-10086); int att = rand() % 100; if (att>=42&&att<45) { xx++; cout << "第" << i << "分钟,蓝方进球!目前比分" << xx << ':' << yy << endl; } else if(att>57&&att<=60){ yy++; cout << "第" << i << "分钟,红方进球!目前比分" << xx << ':' << yy << endl; } Sleep(200); } cout << endl; cout << "比赛结束!\n"; int win; if (xx > yy) { cout << "蓝方胜!\n"; win = 0; } else if (yy > xx) { cout << "红方胜!\n"; win = 1; } else { cout << "平局!\n"; win = -1; } if (win == x) { money += cost * qwe * 2; cout << "恭喜你,赌对了,获得" << cost * qwe*2 << "元!\n"; } else if (win == -1) { money += cost; cout << "你赌对了也赌错了,获得" << cost << "元!\n"; } else { cout << "很遗憾,你赌错了。\n"; money-=cost*(qwe-1); } cout << "你剩余资产" << money << "元\n\n"; Sleep(2000); } } Max = max(Max, money); } cout << "你的巅峰资产:" << Max << "元。\n"; cout << "游戏结束!"; return 0; }