Cod sursa(job #1906309)

Utilizator justsomedudePalade Thomas-Emanuel justsomedude Data 6 martie 2017 13:16:49
Problema Submultimi Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.59 kb
#include<fstream>
#include<iostream>
using namespace std;
ifstream fin  ("submultimi.in");
ofstream fout ("submultimi.out");

int st[17], n;
int ok;
void Citire()
{
  fin >> n;
}

void Afisare()
{
   int i;
   if (ok==1)
   {
    for (i=1; i<=n; i++)
    if (st[i]== 1)
     fout << i << " ";

    fout << "\n";
   }
   ok = 1;
}

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

int main ()
{
  Citire();
    Back(1);
  fin.close();
  fout.close();
  return 0;
}