How can I get random numbers 0 to 10^9 (without duplicates) and store them in an array .
First of all, I am unsure of how to declare an array of size 10^9 (I am able to declare an array up to size 10^8) . Second of all, I do not know how to store random numbers without duplicates in it.
This is my code so far:
#include<bits/stdc++.h>
using namespace std;
#define S 100000000
int main()
{
int i;
std::vector<int>result(S);
for( i = 1; i < S ; ++i)
{
int t = rand() % i; // t - is random value in [0..i)
result[i] = result[t]; // i-th element assigned random index-th value
result[t] =i; // and, random position assigned i value
}
}
How can I accomplish my goal?