Exemple de mot clé Break avec Label: Recherche dans un tableau à 2 dimensions

Author:


{filelink=4315}


public class BreakAvecLabelDemo {
    public static void main(String[] args) {

        int[][] arrayDeInts = { { 32, 87, 3, 589 },
                                { 12, 1076, 2000, 8 },
                                { 622, 127, 77, 955 }
                              };
        int rechercheVal = 12;

        int i = 0;
        int j = 0;
        boolean trouvé = false;

    search:
        for ( ; i < arrayDeInts.length; i++) {
            for (j = 0; j < arrayDeInts[i].length; j++) {
                if (arrayDeInts[i][j] == rechercheVal) {
                    trouvé = true;
                    break search;
          }
            }
        }

        if (trouvé) {
      System.out.println(rechercheVal +" Trouvé " +  " à l'index " + i + ", " + j);
        } else {
            System.out.println(rechercheVal + "n'existe pas dans le tableau à deux dimensions");
        }

    }
}

A Voir sur le même Sujet:

  • mots-clés tableau exemple
  • c# tableau 2 dimensions recherche cle
  • Python+structure+"tableau+à+2+dimensions"

Leave a Reply

Your email address will not be published. Required fields are marked *