Cod sursa(job #1989734)
| Utilizator | Data | 8 iunie 2017 17:47:00 | |
|---|---|---|---|
| Problema | Combinari | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.56 kb |
#include<fstream>
using namespace std;
#define MAX 18
int comb[MAX+1];
void printSol(int k,ofstream &out){
for(int i=1;i<=k;i++) out<<comb[i]<<" ";
out<<"\n";
}
void back(int where, int k, int n, ofstream &out){
if(where==k+1) printSol(k,out);
else{
for(int i=comb[where-1]+1;i<=n;i++){
comb[where]=i;
back(where+1,k,n,out);
}
}
}
int main(){
ifstream in; ofstream out;
in.open("combinari.in"); out.open("combinari.out");
out.clear();
int k,n;
in>>n>>k;
back(1,k,n,out);
return 0;
}
