Cod sursa(job #542967)

Utilizator AndrewTheGreatAndrei Alexandrescu AndrewTheGreat Data 27 februarie 2011 12:32:07
Problema Submultimi Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.46 kb
#include <stdio.h>

using namespace std;

int N, up, i, temp, j;

int main()
{
    freopen ("submultimi.in","r",stdin);
    freopen ("submultimi.out","w",stdout);
    scanf("%d",&N);
    up = 1 << N;
    for(i = 1; i < up; i++)
    {
        j = 1;
        temp = i;
        while(temp){
            if(temp & 1)
                printf("%d ",j);
            j++;
            temp = temp >> 1;
        }
        printf("\n");
    }
    return 0;
}