The thing is, if we can't see the code, we can't fix the problems. The logical control statements in the code you posted can't possibly be the same as the ones in your actual code, because they're not legal, so if there's any errors in those in your actual code, we can't know what they are.
One thing I would say is make sure you're using braces to correctly contain your conditional code blocks. Also, you will help yourself a lot if you use a consistent, sensible indentation style, because that will make it easier for
you to see and fix mistakes. When I see something like:
23 24 25 26 27
|
if(equal)
// If the current number has previously been drawn it decreases the array by 1 to redo the step until it gets a number not used.
i--;
equal=false;
|
It immediately sets off alarm bells, because it looks as though you intended
equal=false;
to be part of the code that only executes if the condition is true, but it will, of course, execute whatever the result of the condition is.
I'd go so far as to recommend using braces even when your conditional block only has a single code statement, to avoid making this kind of error as you edit your code. So, for example, you should prefer:
17 18 19 20 21 22 23 24 25 26
|
for(int j=1; j<i; j++)
{
// Iterating the previously drawn numbers and cross checks it with the current number
if(lotterynumber[i]=lotterynumber[j])
{
equal=true;
}
}
|
over what you wrote, because then if you go back and add extra lines to those blocks, you won't accidentally screw up the logic.