Pagini recente » Cod sursa (job #780542) | Cod sursa (job #2027259) | Cod sursa (job #1840722) | Diferente pentru problema/dummy intre reviziile 7 si 6 | Cod sursa (job #1809923)
#include <bits/stdc++.h>
using namespace std;
const char* IN = "combinari.in";
const char* OUT = "combinari.out";
const int Nmax = 20;
namespace InputStream {
FILE *in = fopen(IN,"r");
int nextInt(){
int aux;
fscanf(in,"%d",&aux);
return aux;
}
}
namespace PrintStream {
FILE *out = fopen(OUT,"w");
void printInt(int nbr){
fprintf(out,"%d ",nbr);
}
void endline(){
fprintf(out,"\n");
}
}
namespace Math {
vector <int> st(0);
void generateComb(int n,int k,int step){
if (step>=k) {
for_each(st.begin(),st.end(),PrintStream::printInt);
PrintStream::endline();
return;
}
for (int i=1;i<=n;++i){
if (step == 0 || i>st[step-1]) {
st.push_back(i);
generateComb(n,k,step+1);
st.pop_back();
}
}
}
}
int main(void){
int n = InputStream::nextInt();
int k = InputStream::nextInt();
Math::generateComb(n,k,0);
return 0;
}