Cod sursa(job #471501)
| Utilizator | Data | 19 iulie 2010 11:00:51 | |
|---|---|---|---|
| Problema | Combinari | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.56 kb |
#include<fstream>
using namespace std;
ifstream fin ("combinari.in");
ofstream fout ("combinari.out");
int n,x,a[20],viz[20];
void comb(int k){
int i;
if(k>x){
for(i=1;i<=x;++i){
fout<<a[i]<<" ";
}
fout<<"\n";
}
else{
for(i=a[k-1]+1;i<=n;i++){
if(viz[i]==0){
viz[i]=1;
a[k]=i;
comb(k+1);
viz[i]=0;
}
}
}
}
int main (){
fin>>n>>x;
comb(1);
return 0;
}
