Pagini recente » Cod sursa (job #2783077) | Cod sursa (job #2132153) | Cod sursa (job #1192033) | Cod sursa (job #1338277) | Cod sursa (job #1989732)
#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;
}