| | |
random numbers all different???
![]() |
•
•
Join Date: Apr 2003
Posts: 1
Reputation:
Solved Threads: 0
int upper;
cout << "#s (4 - 9) ";
cin >> upper;
for (int count = 0; count < 4; count++)
{
int y;
srand((unsigned)time(0));
y = (rand()%upper)+1;
cout << y<< endl;
key[count] = y;
Sleep (1000);
}
this is my random number gen and i was wondering if there was a way to have it generate 4 different random numbers indtead of just four im basically either looking for something to change the rand so they all come out different or to change it over after the fact i thought it was easy you know just throw a loop in here with a if statment but when i do that it sends it into and infinate loop well thanks for you help
cout << "#s (4 - 9) ";
cin >> upper;
for (int count = 0; count < 4; count++)
{
int y;
srand((unsigned)time(0));
y = (rand()%upper)+1;
cout << y<< endl;
key[count] = y;
Sleep (1000);
}
this is my random number gen and i was wondering if there was a way to have it generate 4 different random numbers indtead of just four im basically either looking for something to change the rand so they all come out different or to change it over after the fact i thought it was easy you know just throw a loop in here with a if statment but when i do that it sends it into and infinate loop well thanks for you help
![]() |
Similar Threads
- Compile time errors in C++ while generating random numbers (C++)
- C++ Random Numbers (C++)
- C++ Reorder random numbers (C++)
Other Threads in the C++ Forum
- Previous Thread: 3D GameStudio
- Next Thread: What Language is used in software like Adobe Photoshop?
| Thread Tools | Search this Thread |
api array asterisks based binary bitmap c++ c/c++ char class classes code coding compile console conversion count delete deploy desktop developer directshow dissertationtopic dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer interest java knowledge languagerosettastone lib linkedlist linker loop looping loops map math matrix memory msuhangman multiple news node nodes objects output pointer polynomial problem program programming project python random read recursion reference rpg space stop string strings temperature template test text text-file tree url variable vector video warcraft3 win32 windows winsock wordfrequency wxwidgets





