Cod sursa(job #2179657)

Utilizator radugheoRadu Mihai Gheorghe radugheo Data 20 martie 2018 13:08:33
Problema Submultimi Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.54 kb
#include <fstream>

using namespace std;
ifstream fin ("submultimi.in");
ofstream fout ("submultimi.out");
int n, i, ok, v[10001];
int main()
{
    fin >> n;
    while (v[0] == 0){
        i = n;
        while (v[i] == 1){
            v[i] = 0;
            i--;
        }
        v[i] = 1;
        ok = 0;
        for (i=1; i<=n; i++){
            if (v[i] == 1){
                fout << i << " ";
                ok = 1;
            }
        }
        if (ok != 0){
            fout << "\n";
        }
    }
    return 0;
}