Cod sursa(job #448196)
| Utilizator | Data | 3 mai 2010 09:20:23 | |
|---|---|---|---|
| Problema | Submultimi | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.53 kb |
#include<cstdio>
#include<bitset>
using namespace std;
#define NM 17
#define sh short int
bitset<NM>viz;
short int n,nr;
int N;
void div(int x)
{
while (x)
{
viz[++nr]=x&1;
x>>=1;
}
}
void afis()
{
for (sh i=1; i<=nr; ++i)
if (viz[i])
printf("%d ",i);
printf("\n");
}
int main()
{
freopen("submultimi.in","r",stdin);
freopen("submultimi.out","w",stdout);
scanf("%hd",&n);
N=(1<<n)-1;
int i;
for (i=1; i<=N; ++i)
{
viz.reset();
nr=0;
div(i);
afis();
}
return 0;
}
