Cod sursa(job #809718)
Utilizator | Data | 8 noiembrie 2012 22:01:43 | |
---|---|---|---|
Problema | Submultimi | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.29 kb |
#include<fstream>
using namespace std;
ifstream f("submultimi.in");
ofstream g("submultimi.out");
int n, p, i, j, m[32];
int main()
{ f>>n;
for(i=1; i<=n; ++i) m[i]=1<<(i-1);
p=1<<n;
for(i=1; i<p; ++i)
{ for(j=n; j>=1; --j) if(i & m[j]) g<<j<<' ';
g<<'\n';
}
return 0;
}