My code now can generate random numbers ranged from 1-20. but repeats are still there. How do I randomize their orders? That must be a way to erase repeats.
#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std;
int main()
{
srand(time(NULL));
int random_integer;
for(int index = 0; index < 20; index++){
random_integer = (rand() % 20)+1;
cout << random_integer << endl;
}
}

New Topic/Question
Reply


MultiQuote




|