请你看我这个C++程序#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>

// 模拟抽卡函数
bool simulatePull(bool& guaranteed, int& pullCount, int poolType) {
    double baseRate = 0.006;
    int pityStart = (poolType == 1) ? 73 : 63;
    int hardPity = (poolType == 1) ? 90 : 80;
    double rateIncrease = 0.062;

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

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

    if (gotGold) {
        pullCount = 0;
        if (guaranteed || (static_cast<double>(std::rand()) / RAND_MAX) < ((poolType == 1) ? 0.5 : 0.25)) {
            guaranteed = false;
            return true; // Featured item
        } else {
            guaranteed = true;
            return false; // Non-featured item
        }
    } else {
        pullCount += 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 || weaponObtained < weaponCount) {
            if (roleObtained < roleCount && simulatePull(guaranteedRole, rolePullCount, 1)) {
                roleObtained++;
            }
            pulls++;
            if (roleObtained == roleCount) {
                if (simulatePull(guaranteedWeapon, weaponPullCount, 2)) {
                    weaponObtained++;
                }
                pulls++;
            }
        }

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

// 模拟道具数量下的成功率
double simulateWithItems(int roleCount, int weaponCount, int items, int initialRolePulls, int initialWeaponPulls, bool majorPity) {
    int successfulSimulations = 0;
    for (int i = 0; i < 10000; ++i) {
        int pulls = 0;
        bool guaranteedRole = false, guaranteedWeapon = false;
        int roleObtained = 0, weaponObtained = 0;
        int rolePullCount = initialRolePulls, weaponPullCount = initialWeaponPulls;

        while (pulls < items) {
            if (roleObtained < roleCount && simulatePull(guaranteedRole, rolePullCount, 1)) {
                roleObtained++;
            }
            pulls++;
            if (roleObtained == roleCount && pulls < items) {
                if (simulatePull(guaranteedWeapon, weaponPullCount, 2)) {
                    weaponObtained++;
                }
                pulls++;
            }

            if (roleObtained >= roleCount && weaponObtained >= weaponCount) {
                successfulSimulations++;
                break;
            }
        }
    }
    return static_cast<double>(successfulSimulations) / 10000.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);
        std::cout << averagePulls << std::endl;

    } else if (function == "-simulate") {
        if (argc < 8) {
            std::cerr << "Usage: " << argv[0] << " -simulate <roleCount> <weaponCount> <items> <initialRolePulls> <initialWeaponPulls> <majorPity>" << 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 majorPity = std::stoi(argv[7]);
        double successRate = simulateWithItems(roleCount, weaponCount, items, initialRolePulls, initialWeaponPulls, majorPity);
        std::cout << successRate * 100.0 << "%" << std::endl;

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

    return 0;
}