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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
package alouha;
public class vecteur{
public static void binaire(int n, int m) {
for ( int i = m-1; i >= 0; i--)
System.out.print(((n >> i ) & 1 ));
System.out.print("\t");
}
public static void vecteur(int n, int k,int classe){
int l=n-k;
int cp=0;
double m = Math.pow(2,l);
for(int i=0;i<m;i++)
{
int res1=(int)(Math.pow(2,i));
if(i<n-1)
{
binaire(res1,n);
cp++;
}
else
if ((i==n-1))
{
while (cp<classe)
{
binaire ((int)(Math.pow(2,n-1)),n);
cp++;
for(int j=1;j<=i;j++)
{
int res2=(int)(Math.pow(2,i))+(int)(Math.pow(2,i-j));
binaire (res2,n);
cp++;
}
}
}
}
}
public static void main (String[] args){
int n=Integer.parseInt(args[0]);
int k=Integer.parseInt(args[1]);
int g=Integer.parseInt(args[2]);
vecteur( n, k,g);
}
} |
Partager