改编自(leo1009)的老虎机2.0pro(换行版)

lizexu 2026-08-17 21:53:22 2026-08-17 21:55:04

#include<bits/stdc++.h>

using namespace std;

double n, money = 100;

bool flag = false;

string s[10] = {"菠萝", "香蕉", "草莓", "柠檬", "葡萄", "西瓜", "橙子", "椰子"};

int main() { n = 100; cout << "~欢迎来到老虎机~" << endl;

label1:

long long o, times = 0;

while(n != 0)
{
    cout << "请输入押金(押金越多奖金越多)\n";

    cin >> o;

    times++;

    int a = abs(rand() % 8);
    int b = abs(rand() % 8);
    int c = abs(rand() % 8);

    system("cls");
    cout << "下面是中奖结果: " << endl << s[a] << " " << s[b] << " " << s[c] << endl;

    if((a + b + c) / 3 == a && (a + b + c) / 3 == b && (a + b + c) / 3 == c)
    {
        if(flag)
        {
            double bonus = (o + o / 2 + times) * 3;
            cout << "\n恭喜您中奖了!!!奖金:" << bonus << "\n";
            n += bonus;
            flag = false;
        }
        else
        {
            double bonus = o + o / 1.2 + times;
            cout << "\n恭喜您中奖了!!!奖金:" << bonus << "\n";
            n += bonus;
        }
    }
    else if(times >= 15 && !flag)
    {
        cout << "疯狂模式!!!(中奖金额翻三倍)\n";
        flag = true;
        times = 0;
    }
    else
    {
        n -= o;
    }

    cout << "剩余mop: " << n << "\n";
}

cout << "\n很抱歉,您的余额不足,请充值!!!\n";

label2: system("cls"); cout << "\n剩余 = 150mop|\n|300 = 750mop|\n---------------\n";

double c;

cin >> c;

if(money == 0)
{
    return 0;
}

if(c <= money)
{
    cout << "充值成功!!!\n";

    n += c * 1.5;

    money -= c;

    cout << "\n剩余$" << money << "\n";

    goto label1;
}
else
{
    cout << "您的余额不足!!!\n";

    goto label2;
}

system("cls");

return 0;

}

共 1 条回复

leo1009

感谢