随机无法创建大数字c ++

时间:2018-01-12 10:06:27

标签: c++ random

我为我的代码编写了一个简单的随机生成器,它的工作非常完美。 只有promblem它不会创建任何大于5位的数字。

int *numbers;

void Random()
{

    srand(time(NULL));

    cout << "Choose the amounth of the random values to create: ";
    cin >> amount;

    int max;

    cout << "Choose the max limit of the random numbers: ";
    cin >> max;

    numbers = new int[amount];

    //Create random
    for (int i = 0; i < amount; i++)
    {
        randomNumber = rand() % max;
        numbers[i] = randomNumber;
        cout << randomNumber << endl;
    }

}
  

当max为1.000(金额10)时:
  输出:12,565,404,250,745,941,814,83,277,518

     

当max为100.000(金额10)时:
  输出:2592,7665,16438,10927,30746,10054,22957,12322,7029,   9814

     

当max为10.000.000(金额10)时:
  输出:2931,11387,6​​536,23144,22117,25218,18972,2797,20299,   25775

我想也许这是我的运气,为什么他们那么小,我多次尝试。 即使我赚了数千也没什么变化,总是很小的数字。

0 个答案:

没有答案
相关问题