The code below will print out:
Row: 0, Col: 0, p: 0, m: 0
Row: 0, Col: 1, p: 0, m: 0
Row: 0, Col: 2, p: 0, m: 0
Row: 1, Col: 0, p: 0, m: 0
Row: 1, Col: 1, p: 0, m: 0
Row: 1, Col: 2, p: 0, m: 0
Row: 2, Col: 0, p: 0, m: 0
Row: 2, Col: 1, p: 0, m: 0
Row: 2, Col: 2, p: 0, m: 0
Row: 0, Col: 3, p: 3, m: 0
Row: 0, Col: 4, p: 3, m: 0
Row: 0, Col: 5, p: 5, m: 0
Row: 0, Col: 6, p: 5, m: 0
Row: 0, Col: 7, p: 5, m: 0
etc.
Can someone please let me know why p suddenly changes to 5 (everything is fine before that). This is really annoying me and has to be sorted tonight.
Thanks in advance.
Row: 0, Col: 0, p: 0, m: 0
Row: 0, Col: 1, p: 0, m: 0
Row: 0, Col: 2, p: 0, m: 0
Row: 1, Col: 0, p: 0, m: 0
Row: 1, Col: 1, p: 0, m: 0
Row: 1, Col: 2, p: 0, m: 0
Row: 2, Col: 0, p: 0, m: 0
Row: 2, Col: 1, p: 0, m: 0
Row: 2, Col: 2, p: 0, m: 0
Row: 0, Col: 3, p: 3, m: 0
Row: 0, Col: 4, p: 3, m: 0
Row: 0, Col: 5, p: 5, m: 0
Row: 0, Col: 6, p: 5, m: 0
Row: 0, Col: 7, p: 5, m: 0
etc.
Can someone please let me know why p suddenly changes to 5 (everything is fine before that). This is really annoying me and has to be sorted tonight.
Thanks in advance.
Code:
int row, col, n, m, p, q;
Cellgroup cgroup;
Coord co;
m = 0;
p = 0;
q = 0;
n = 0;
while(m<=6) {
while(p<=6) {
for(row=m; row<m+3; row++) {
for(col=p; col<p+3; col++) {
co.r = row;
co.c = col;
cgroup.grp[q] = co;
q++;
printf("Row: %d, Col: %d, p: %d, m: %d\n",row, col, p, m);
}
printf("\n");
}
group[n] = cgroup;
n++;
p+=3;
}
p=0;
m+=3;
}