This if is not working as intended, it should "reset" the variable "n" to 0, when it reaches 3, but instead, it does that until 5.
I tried to print "n" without the if and it is giving the values I want.
0 1 2 3 4 5 6 8 9
But when comparing them, it is like I stated that 5 should be the "cap" to compare the actual value of "n".
for (int i = 0; i < size //4 for the sake of the example; i++){
if (n //value 0 == aux2 //4-1 = 3) {
n = 0;
}
x = 0;
y = i;
for (int j = 0; j <= i; j++) {
System.out.println(aux+" "+n);
x++;
y--;
n++;
aux++;
}
if (aux //also 0 at the beginning == aux2) {
m++ //also 0 at the beginning;
aux=0;
}
}
Excpected output: 0 1 2 3 0 1 2 3 0 1 Given output: 0 1 2 3 4 5 0 1 2 3
Aucun commentaire:
Enregistrer un commentaire