1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| package combinaisons;
import java.util.Random;
public class melange_de_combinaison {
public static void main(String[] args) {
int tab[] = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30};
// appel methode initialiser(tab);
int i, j, k;
for (i = 0; i < tab.length; i++) {
// remplir le tableau de 1 a 30
}
// appel methode melanger [tab]
Random r = new Random();
for (k = 0; k < 100; k++)// repeter le melange 100 fois
{
i = r.nextInt(30);
j = r.nextInt(30);
int temp = tab[i];
tab[i] = tab[j];
tab[j] = temp;
}
afficher(tab);
}
public static void afficher(int tab[]) {
System.out.println("La combinaison gagnante est: ");
for (int i = 0; i < tab.length; i++) {
System.out.print(tab[i] + " ");
}
System.out.println("");
}
} |
Partager