Cod sursa(job #1743640)
Utilizator | Data | 18 august 2016 15:10:03 | |
---|---|---|---|
Problema | Submultimi | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.55 kb |
#include <cstdio>
using namespace std;
int n;
void citire()
{
scanf("%d", &n);
}
void afisareSubmultimi()
{
int limita = (1 << n);
for(int k = 1; k < limita; k++)
{
for(int i = 0; i < n; i++)
{
if((k & (1 << i)) != 0)
{
printf("%d ", i + 1);
}
}
printf("\n");
}
}
int main()
{
freopen("submultimi.in", "r", stdin);
freopen("submultimi.out", "w", stdout);
citire();
afisareSubmultimi();
return 0;
}