小编Mak*_*ako的帖子

C++随机整数似乎总是相同的

对于我当前的项目,我创建了一个事件,该事件应该根据我的代码生成的随机整数而改变,唯一的问题是我似乎总是得到相同的路径.总之,我希望它发生任何事件的几率为50%.谢谢,西蒙

random1 = rand() % 1 + 0;
    if (random1 == 0) {
        int choice4;
        cout << "Your character screams at the top of his lungs, " << endl;
        cout << "this causes the dragon to immediately to bow in fear..." << endl;
        cout << "It turns out dragons are very sensitive to hearing....." << endl;
        system("pause");
        cout << "\nIt seems the dragon is requesting you ride it!\n" << endl;
        cout << "Will you ride it?\n" << endl;
        cout << …
Run Code Online (Sandbox Code Playgroud)

c++ random events integer

-3
推荐指数
1
解决办法
113
查看次数

标签 统计

c++ ×1

events ×1

integer ×1

random ×1