
-----------------------------------
ExcuisiteSquid
Wed Mar 27, 2013 5:02 pm

Help with randint in looping
-----------------------------------
What is it you are trying to achieve?



What is the problem you are having?



Describe what you have tried to solve this problem



Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)








Please specify what version of Turing you are using


-----------------------------------
Raknarg
Wed Mar 27, 2013 5:22 pm

RE:Help with randint in looping
-----------------------------------
Try that again

-----------------------------------
Cancer Sol
Wed Mar 27, 2013 5:52 pm

Re: Help with randint in looping
-----------------------------------
What exactly are you having trouble with your randint within the loop?
I'll just take a guess here, but it's probably not what you want.
What I used to have trouble with is having the randint generate a new random value each time the loop restarts.
I'm not sure how to show it in turing, I'll just post the code in C++.

#include 
#include 
#include 
using namespace std;

int randRange (int low, int high)
{
	return rand() % ( high - low + 1 ) + low;
}

int main ()
{
	srand(time(NULL));
	for (int i=0; i