Cod sursa(job #1916906)

Utilizator adiXMGemene Adrian adiXM Data 9 martie 2017 10:38:43
Problema Submultimi Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.62 kb
#include <bits/stdc++.h>

using namespace std;
ifstream f("submultimi.in");
ofstream g("submultimi.out");
const int nMax = 20;
int St[nMax];
int n;
inline void Back(int top) {
    if(top == n + 1) {
        bool ok = 0;
        for(int i = 1; i <= n; i++) {
            if(St[i] == 1) {
                ok = 1;
                g << i << " ";
            }
        }
        if(ok) {
            g << "\n";
        }

    }
    else {
        for(int i = 0; i <= 1; i++) {
            St[top] = i;
            Back(top + 1);
        }
    }
}
int main()
{
    f >> n;
    Back(1);
    return 0;
}