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 39 40 41 42 43 44 45 46 47
| public class test {
static public int[][] combinaison(double map [],int nbr)
{
int [][]tab=new int [((int) Math.pow(nbr, map.length))][map.length];
int ligne=0;
int nb=1;
int k=0;
for(int i=0;i<map.length;i++)
{
while(ligne<((int) Math.pow(nbr, map.length)))
{
for(int ll=(nbr-1);ll>=0;ll--)
{
while(k<nb)
{
tab[ligne][map.length-(i+1)]=ll;
k++;
ligne++;
}
k=0;
}
}
ligne=0;
nb*=nbr;
}
return tab;
}
public static void main(String[] args) {
MyBinaryArray b= new MyBinaryArray() ;
double typetab[]=new double[]{30.1,20.0};
b.afficheSolutionPersonaliser(combinaison(typetab,3));
}
} |
Partager