vendredi 30 mars 2018

My IF wont work?

when i make adjoint inverse program, i found a problem like this

         for(byte f = 0; f < 3; f++){
                for (byte g = 0; g < 3; g++){
                    if(proses[f][g] != 51251) {

                        loop:
                        for(byte h = 0; h < 2; h++){
                            for (byte i = 0; i < 2; i++){
                                if(hasil [h][i] == 0) {
                                    hasil [h][i] = proses [f][g];
                                    System.out.printf("Hasil dari [%d][%d]: %d%n", h, i, proses[f][g]);
                                    break loop;
                                }
                             }
                        }
                        for(byte h = 0; h < 2; h++){
                            for (byte i = 0; i < 2; i++){
                                System.out.print(hasil [h][i]+ ", ");
                            } System.out.println("");
                        }
                    }    
                }
            }

its print like this

Hasil dari [0][0]: 5
5, 0,
0, 0,
Hasil dari [0][0]: 2
2, 0, 
0, 0, 
Hasil dari [0][0]: 2
2, 0, 
0, 0, 

why this if(hasil [h][i] == 0)do something strange? i want to convert and array with length 3x3 to 2x2.

anyone can explain this, please?

Aucun commentaire:

Enregistrer un commentaire