Filling an array with random numbers from 1 to 10^10 in C or C++

前端 未结 6 1174
你的背包
你的背包 2021-01-27 09:50

a part of an assignment of mine is based on an array (its size is given by the user) which contains random numbers from 1 to 10^10. Then we have to find the k-th smaller number

6条回答
  •  攒了一身酷
    2021-01-27 10:39

    Problem #1, an int will only hold a number of size 2^31 in size. You'll need a slightly bigger alternative for your pin array.

    Also, multiplying your two random numbers together really doesn't do much - except perhaps make the number less random.

    Next, you can't create an array on the stack dynamically with the user's input. That will require a new solution to make alloc an array for you.

提交回复
热议问题