Pagini recente » Cod sursa (job #2365319) | Monitorul de evaluare | Cod sursa (job #2166949) | Cod sursa (job #457358) | Cod sursa (job #1536369)
// http://www.infoarena.ro/problema/submultimi
#include <fstream>
#include <iostream>
using namespace std;
int main(int argc, const char *argv[])
{
ifstream f{"submultimi.in"};
ofstream g{"submultimi.out"};
int n;
f >> n;
int nsets = 1 << n;
unsigned int set = 1;
for (int i = 0; i < nsets - 1; i++) {
for (int j = 0; j < n; j++) {
if ((set & (1 << j)))
g << j + 1 << " ";
}
g << '\n';
set += 1;
}
return 0;
}