Cod sursa(job #1180546)
Utilizator | Data | 30 aprilie 2014 18:56:26 | |
---|---|---|---|
Problema | Combinari | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.5 kb |
#include<fstream>
using namespace std;
ofstream out("combinari.out");
int N,K,v[22];
void citire(){
ifstream in("combinari.in");
in>>N>>K;
in.close();
}
void Combinari(int l) {
int i;
if(l>K) {
for(i=1;i<=K;i++)
out<<v[i]<<' ';
out<<'\n';
}
else {
for(i=v[l-1]+1;i<=N;i++) {
v[l]=i;
Combinari(l+1);
}
}
}
int main() {
citire();
Combinari(1);
return 0;
}