•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 392,047 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,318 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:
Views: 2128 | Replies: 1
![]() |
•
•
Join Date: Feb 2005
Posts: 4
Reputation:
Rep Power: 0
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
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 3:44 pm. Reason: added [code] tags
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
Similar Threads
- how to count integer from random number (C)
- need help, need to generate 10 random numbers, such that their sum is less than 1 (C)
- Loop challenge (C)
- Random sequence in an array? (C++)
- C++ Loop Question Here (C++)
- Show the number not again and again (Visual Basic 4 / 5 / 6)
- Writing a Hangman game (C++)
- How do i create a simple game using c++?? (C++)
Other Threads in the C++ Forum
- Previous Thread: Trying to remember !@#$%#
- Next Thread: max int value?


Linear Mode