全部评论 2

  • kirka.io

    5天前 来自 浙江

    0
  • #include <iostream>
    #include <cstdlib>
    #include <ctime>
    #include <iomanip>
    #include <string>

    using namespace std;

    // 全局变量:玩家资金
    int money = 2000;

    // 显示游戏菜单
    void showMenu() {
    system("cls"); // 清屏(Windows系统适用)
    cout << "" << endl;
    cout << " 简易小游戏 " << endl;
    cout << "
    " << endl;
    cout << "当前资金: " << money << " 元" << endl;
    cout << "--------------------------------------" << endl;
    cout << "1. 猜大小 (赔率 1:1)" << endl;
    cout << "2. 猜数字 (赔率 1:9)" << endl;
    cout << "3. 扑克牌比大小 (赔率 1:1)" << endl;
    cout << "4. 退出游戏" << endl;
    cout << "======================================" << endl;
    cout << "请选择玩法: ";
    }

    // 猜大小游戏
    void guessBigSmall() {
    if (money <= 0) {
    cout << "您已没有资金,无法继续游戏!" << endl;
    system("pause");
    return;
    }

    int bet;
    cout << "\n----- 猜大小 -----" << endl;
    cout << "请输入赌注 (1-" << money << "): ";
    cin >> bet;
    
    if (bet <= 0 || bet > money) {
        cout << "无效的赌注!" << endl;
        system("pause");
        return;
    }
    
    int choice;
    cout << "请猜大小 (1=小 [1-3], 2=大 [4-6]): ";
    cin >> choice;
    
    if (choice != 1 && choice != 2) {
        cout << "无效的选择!" << endl;
        system("pause");
        return;
    }
    
    // 生成1-6的随机数(模拟骰子)
    int dice = rand() % 6 + 1;
    cout << "骰子点数: " << dice << endl;
    
    bool win = false;
    if ((choice == 1 && dice <= 3) || (choice == 2 && dice >= 4)) {
        win = true;
        money += bet;
        cout << "恭喜您赢了!赢得 " << bet << " 元" << endl;
    } else {
        money -= bet;
        cout << "很遗憾,您输了 " << bet << " 元" << endl;
    }
    
    system("pause");
    

    }

    // 猜数字游戏
    void guessNumber() {
    if (money <= 0) {
    cout << "您已没有资金,无法继续游戏!" << endl;
    system("pause");
    return;
    }

    int bet;
    cout << "\n----- 猜数字 -----" << endl;
    cout << "请输入赌注 (1-" << money << "): ";
    cin >> bet;
    

    2025-11-03 来自 浙江

    0
暂无数据

提交答案之后,这里将显示提交结果~

首页