Cod sursa(job #1231931)

Utilizator vtt271Vasile Toncu vtt271 Data 21 septembrie 2014 19:01:06
Problema Combinari Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.62 kb
#include <fstream>

using namespace std;

ifstream inFile("permutari.in");
ofstream outFile("permutari.out");

int S[30], n, m;

int print()
{
    for(int i = 1; i <= m; i++) outFile << S[i] << " ";
    outFile << "\n";
}

bool check(int level)
{
    for(int i = 1; i < level; i++){
        if( S[level] <= S[i]) return false;
    }

    return true;
}

void gen(int level)
{
    if(level == m+1) print();
    else{
        for(int i = 1; i <= n; i++){
            S[level] = i;
            if( check(level) ) gen(level+1);
        }
    }
}


int main()
{
    inFile >> n >> m;
    gen(1);
}