je sais coment le faire pour une ligne
public class TestSudoku { public static void main(String[] args) { int col, temp=0; int nbChiffres[]; // vecteur de 10 compteurs nbChiffres = new int[10]; int sud[][] = { { 7,0,0, 0,9,5, 4,0,8 }, { 0,0,0, 8,0,4, 3,7,0 }, { 0,0,0, 0,0,0, 0,5,1 }, { 3,7,0, 4,1,2, 0,0,0 }, { 0,4,0, 0,0,0, 0,2,0 }, { 0,0,0, 5,3,9, 0,4,6 }, { 6,8,0, 9,0,0, 0,0,0 }, { 0,5,1, 2,0,3, 0,0,0 }, { 2,0,3, 6,4,0, 0,0,7 } }; //Déterminer le nombre d'occurrence à la ligne 0 for(col = 0; col <=8; col++){ temp = sud[0][col]; nbChiffres[temp]++; } for(col=1; col < nbChiffres.length; col++){ if(nbChiffres[col] >= 2){ System.out.println(col +" se produit "+ nbChiffres[col]+" à la ligne 0"); }else { if(nbChiffres[col] > 0 && nbChiffres[col] == 1){ System.out.println(col +" se produit "+ nbChiffres[col]+" à la ligne 0"); } } } } }
27 nov. 2020 à 21:46
Par example ça m'affiche en autres:
"5 se produit 1 fois à la ligne 1" alors qu'il n'y a aucun 5 à la ligne 1
27 nov. 2020 à 22:09