can't figure this out
That, too, will loop forever. The proper way is this:
1 2 3
|
while (a-b>0) {
a -= b;
}
|
[edit] But Moschops' trick is much more elegant.
Last edited on
Oh God!! That's what comes of not sleeping by midnight!
The final correction (it becomes the same as yours after that by the way):
1 2 3 4 5
|
int c = a;
while (c-b>0)
{
c = c- b;
}
|
Topic archived. No new replies allowed.