你错误理解majorpity了，majorpity应该是，如果majorpity=1 则立刻设置guaranteed=1 majorpity=0然后模拟，帮我更改，#include <iostream>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <string>

// 模拟角色池的抽卡
bool simulateRolePull(bool& guaranteedRole, int& rolePullCount, bool majorPity) {
    const double baseRate = 0.006;
    const int pityStart = 73;
    const int hardPity = 90;
    const double rateIncrease = 0.062;

    double pullRate = baseRate;
    if (rolePullCount >= pityStart) {
        pullRate += (rolePullCount - pityStart) * rateIncrease;
    }

    bool gotGold = (rolePullCount >= hardPity - 1) || (static_cast<double>(std::rand()) / RAND_MAX) < pullRate;

    if (gotGold) {
        rolePullCount = 0;

        double guaranteedRate = 0.5;  // 角色池初始概率

        if (guaranteedRole || majorPity || (static_cast<double>(std::rand()) / RAND_MAX) < guaranteedRate) {
            guaranteedRole = false;
            return true;  // 获取限定物品
        } else {
            guaranteedRole = true;  // 下次必定限定
            return false;  // 非限定
        }
    } else {
        rolePullCount += 1;
    }
    return false;
}

// 模拟武器池的抽卡
bool simulateWeaponPull(bool& guaranteedWeapon, int& weaponPullCount, bool majorPity) {
    const double baseRate = 0.006;
    const int pityStart = 63;
    const int hardPity = 80;
    const double rateIncrease = 0.062;

    double pullRate = baseRate;
    if (weaponPullCount >= pityStart) {
        pullRate += (weaponPullCount - pityStart) * rateIncrease;
    }

    bool gotGold = (weaponPullCount >= hardPity - 1) || (static_cast<double>(std::rand()) / RAND_MAX) < pullRate;

    if (gotGold) {
        weaponPullCount = 0;

        double guaranteedRate = 0.75;  // 武器池初始概率

        if (guaranteedWeapon || majorPity || (static_cast<double>(std::rand()) / RAND_MAX) < guaranteedRate) {
            guaranteedWeapon = false;
            return true;  // 获取限定物品
        } else {
            guaranteedWeapon = true;  // 下次必定限定
            return false;  // 非限定
        }
    } else {
        weaponPullCount += 1;
    }
    return false;
}

double calculateAveragePulls(int roleCount, int weaponCount) {
    int totalPulls = 0;

    for (int i = 0; i < 10000; ++i) {
        int pulls = 0;
        bool guaranteedRole = false, guaranteedWeapon = false;
        int roleObtained = 0, weaponObtained = 0;
        int rolePullCount = 0, weaponPullCount = 0;

        // 先抽角色池
        while (roleObtained < roleCount) {
            if (simulateRolePull(guaranteedRole, rolePullCount, false)) {
                roleObtained++;
            }
            pulls++;
        }
        // 再抽武器池
        while (weaponObtained < weaponCount) {
            if (simulateWeaponPull(guaranteedWeapon, weaponPullCount, false)) {
                weaponObtained++;
            }
            pulls++;
        }

        totalPulls += pulls;
    }

    return static_cast<double>(totalPulls) / 10000.0;
}

double simulateWithItems(int roleCount, int weaponCount, int items, int initialRolePulls, int initialWeaponPulls, bool majorPityRole, bool majorPityWeapon) {
    int successfulSimulations = 0;
    for (int i = 0; i < 10000; ++i) {
        int pulls = 0;
        bool guaranteedRole = majorPityRole, guaranteedWeapon = majorPityWeapon;
        int roleObtained = 0, weaponObtained = 0;
        int rolePullCount = initialRolePulls, weaponPullCount = initialWeaponPulls;

        // 先抽角色池
        while (roleObtained < roleCount && pulls < items) {
            if (simulateRolePull(guaranteedRole, rolePullCount, majorPityRole)) {
                roleObtained++;
            }
            pulls++;
        }
        // 再抽武器池
        while (weaponObtained < weaponCount && pulls < items) {
            if (simulateWeaponPull(guaranteedWeapon, weaponPullCount, majorPityWeapon)) {
                weaponObtained++;
            }
            pulls++;
        }

        if (roleObtained >= roleCount && weaponObtained >= weaponCount) {
            successfulSimulations++;
        }
    }
    return static_cast<double>(successfulSimulations) / 10000.0 * 100.0;
}

int main(int argc, char* argv[]) {
    if (argc < 2) {
        std::cerr << "Usage: " << argv[0] << " <function> <parameters>..." << std::endl;
        return 1;
    }

    std::srand(std::time(0)); // 设置随机种子

    std::string function = argv[1];
    if (function == "-average") {
        if (argc < 4) {
            std::cerr << "Usage: " << argv[0] << " -average <roleCount> <weaponCount>" << std::endl;
            return 1;
        }
        int roleCount = std::stoi(argv[2]);
        int weaponCount = std::stoi(argv[3]);
        double averagePulls = calculateAveragePulls(roleCount, weaponCount);
        int starJades = static_cast<int>(std::ceil(averagePulls)) * 160;
        std::cout << averagePulls << " " << starJades << std::endl;

    } else if (function == "-simulate") {
        if (argc < 9) {
            std::cerr << "Usage: " << argv[0] << " -simulate <roleCount> <weaponCount> <items> <initialRolePulls> <initialWeaponPulls> <majorPityRole> <majorPityWeapon>" << std::endl;
            return 1;
        }
        int roleCount = std::stoi(argv[2]);
        int weaponCount = std::stoi(argv[3]);
        int items = std::stoi(argv[4]);
        int initialRolePulls = std::stoi(argv[5]);
        int initialWeaponPulls = std::stoi(argv[6]);
        bool majorPityRole = std::stoi(argv[7]);
        bool majorPityWeapon = std::stoi(argv[8]);
        double successRate = simulateWithItems(roleCount, weaponCount, items, initialRolePulls, initialWeaponPulls, majorPityRole, majorPityWeapon);
        std::cout << successRate << "%" << std::endl;

    } else {
        std::cerr << "Invalid function specified." << std::endl;
        return 1;
    }

    return 0;
}