| | |
Random Different Number in each loop ?? HLP Me PLZ (c or c++)
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2005
Posts: 4
Reputation:
Solved Threads: 0
so i have 4 integer that are
int m = rand() % 3+ 0;
int n = rand() % 3 + 0;
int x = rand() % 3 + 0;
int y = rand() % 3 + 0;
and i want to random in 0-3 range so how can i random 4 interger
in different number between 0 - 3 ?? what is loop for this problem ?
exam. Firsttime ; m = 1
n = 0
x = 3
y =2
this is my old code
ps.- Use in c or c++
Thank you.
int m = rand() % 3+ 0;
int n = rand() % 3 + 0;
int x = rand() % 3 + 0;
int y = rand() % 3 + 0;
and i want to random in 0-3 range so how can i random 4 interger
in different number between 0 - 3 ?? what is loop for this problem ?
exam. Firsttime ; m = 1
n = 0
x = 3
y =2
this is my old code
C++ Syntax (Toggle Plain Text)
int main() { srand(time(NULL)); int array[4]; array[0]=rand() % 3 + 0; for(int i=1;i<=3;i++) { array[i]=rand() % 3 + 0; if ((array[i]=array[i-1])||(array[i]=array[i-2])||(array[i] =array[i-3])) { array[i]=rand() % 3 + 0; } } cout<<array[0]<<array[1]<<array[2]<<array[3]<<endl; system("pause"); return 0; }
ps.- Use in c or c++
Thank you.
Last edited by alc6379; Feb 23rd, 2005 at 4:44 pm. Reason: added [code] tags
![]() |
Similar Threads
- C++ Random Number Generator (C++)
- Random Number Problem For Lottery Program (Visual Basic 4 / 5 / 6)
- Checking against a random number (VB.NET)
- Random number generation (C)
- Need aome help in generating a Random Number (C++)
- Random number generator freezing (VB.NET)
- Random number generator (Java)
Other Threads in the C++ Forum
- Previous Thread: Trying to remember !@#$%#
- Next Thread: String Alphabetize
| Thread Tools | Search this Thread |
api application array arrays based binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg simple sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





