Cod sursa(job #2141570)

Utilizator StanCatalinStanCatalin StanCatalin Data 24 februarie 2018 14:22:42
Problema Submultimi Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.65 kb
#include <iostream>
#include <fstream>

using namespace std;

ifstream in("submultimi.in");
ofstream out("submultimi.out");

int n,st[17];

void Afisare()
{
    int i,ok = 0;
    for (i=1; i<=n && ok == 0; i++)
        if (st[i] != 0)
            ok = 1;
    if (ok == 1)
    {
        for (i=1; i<=n; i++)
            if (st[i] != 0)
                out << i << " ";
        out << "\n";
    }
}

void Back(int top)
{
    int i;
    if (top == n+1)
        Afisare();
    else
        for (i=0; i<2; i++)
    {
        st[top] = i;
        Back(top+1);
    }
}

int main()
{
    in >> n;
    Back(1);
    return 0;
}