I have been having some problems with a 'find' loop that Im using. The program is set up to do some calculations using an iterative loop, however I am finding that in most cases it crashes after an indefinite number of cycles. I isolated the problem to a 'find' loop that is being used to generate an array of 'N' variables with specific conditions;
for (int j = 0; j < N; j++)
{
do {
S[j] = rand()%(N);
q = find(S, S + j, S[j]);
} while ((S[j] == j) || (q != S + j));
}
Could anyone tell me how this may cause an infinite loop, or for the program to simply stop in it's tracks? It could simply be a syntax error or something to do with the random no. generator, though I'm not massively sure at this stage (as Im sure you can tell! lol)
Any help on this is much appreciated anyway!
Thanks, Ryan
This post has been edited by shoot to thrill: 01 October 2010 - 11:30 AM

New Topic/Question
Reply




MultiQuote







|