how do i generate random #'s that do not repeat? below is some small code for generating 20 random #s btw 1 and 20...but i don't know how to make sure the sequence of picking the #s does not repeat...
Code:// rgen.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <ctime> #include <cmath> #include <cstdlib> #include <algorithm> #include <fstream> #include <iostream> #include <iomanip> using namespace std; int main() { srand((unsigned)time(0)); int random_integer; for(int index=0; index<20; index++) { random_integer = (rand()%20)+1; cout << random_integer << endl; } }




Reply With Quote