Seems like the outer iteration variable is reset in the inner loop.
Example below.

class Bug {
static  func printCoeff(int K,int M)
$define DEBUG
    int i=0
    int j=0

    while(i<=K)
        ;print("i1=",i)
        while(j<=M)
           if i>0
              ; never get here, i is reset to 0?
              print(i, " ", j)
           endif
           ;print("i2=",i)
           j = j+1
        endwhile
        i = i+1;
    endwhile

endfunc     
}

Bugbrot {
global:
   int K = 2
   int M = 2
   Bug.printCoeff(K,M)
default:
  title = "Bug"
}
Seems like the outer iteration variable is reset in the inner loop. Example below. ```` class Bug { static func printCoeff(int K,int M) $define DEBUG int i=0 int j=0 while(i&lt;=K) ;print(&quot;i1=&quot;,i) while(j&lt;=M) if i&gt;0 ; never get here, i is reset to 0? print(i, &quot; &quot;, j) endif ;print(&quot;i2=&quot;,i) j = j+1 endwhile i = i+1; endwhile endfunc } Bugbrot { global: int K = 2 int M = 2 Bug.printCoeff(K,M) default: title = &quot;Bug&quot; } ````
 
0
reply

You forgot to reset j before repeating the inner loop. The first time through, i is 0 so "if i>0" is false. In subsequent iterations, j will be M+1, so the inner loop will never get executed.

You forgot to reset j before repeating the inner loop. The first time through, i is 0 so &quot;if i&gt;0&quot; is false. In subsequent iterations, j will be M+1, so the inner loop will never get executed.
 
0
reply
83
views
2
replies
2
followers
live preview
Enter at least 10 characters.
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft