int used[ MAX_NUM] = {0}; //zero is 'false'
for (int i = 0; i<4; i++)
{
do{
random = rand() % MAX_NUM;
}while (used[random]) //if its true, its not zero, and you already saw this value
used[random] ++;
cout << random << endl;
}
now you see it in code, but do you understand how it works?
you need a different technique if maxnum becomes huge, but this works for a LOT of small problems of this type. Note that if you wanted 24 of 25 values it could get into a loop for a *while* looking for that last available value, so use the technique when you are not trying to get most of the list.
style stuff...
#define constants are not as nice as
const int MAX_NUM = 25;
the macro ones can give trouble in some code due to implicit type
use <cstdio> <ctime> not the C versions, as the namespace added to the <c***> versions is important and can cause odd behavior in some larger programs.