Cod sursa(job #770970)
Utilizator | Data | 24 iulie 2012 14:24:13 | |
---|---|---|---|
Problema | Submultimi | Scor | 100 |
Compilator | c | Status | done |
Runda | Arhiva educationala | Marime | 0.49 kb |
#include <stdio.h>
#include <math.h>
int main()
{
freopen("submultimi.in", "rt", stdin);
freopen("submultimi.out", "wt", stdout);
char n, j;
scanf("%hhd", &n);
unsigned short i, subs = pow(2,n)-1; // number of subsets
unsigned short cur_sub = 1; // current subset
for ( i=0; i<subs; i++ ) { // iterating through all subsets
for ( j=0; j<n; j++ ) {
if ( cur_sub & 1<<j ) {
printf("%hhd ", j+1);
}
}
printf("\n");
cur_sub++;
}
return 0;
}