| | |
random numbers all different???
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
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 based beginner binary bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number output parameter pointer problem program programming project python read recursion recursive reference return rpg string strings struct temperature template templates test text text-file tree unix url variable vector visualstudio win32 windows winsock word wordfrequency wxwidgets





