Cod sursa(job #2974033)
Utilizator | Scanteie Alexandru alexscanteie | Data | 2 februarie 2023 22:36:27 |
---|---|---|---|
Problema | Combinari | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.51 kb |
#include <fstream>
#include <iostream>
using namespace std;
ifstream fin("combinari.in");
ofstream fout("combinari.out");
int x[20] , n , p;
void Afis(int k)
{
for(int j = 1 ; j <= k ; j ++)
fout << x[j] << " ";
fout << endl;
}
void back(int k){
for(int i = x[k-1] + 1 ; i <= n - k + p ; ++ i)
{
x[k] = i;
if(k == p)
Afis(k);
else
back(k + 1);
}
}
int main(){
fin >> n >> p;
back(1);
return 0;
}