Cod sursa(job #1511902)
Utilizator | Data | 27 octombrie 2015 12:15:38 | |
---|---|---|---|
Problema | Combinari | Scor | 80 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.55 kb |
#include<fstream>
using namespace std;
ifstream fin("combinari.in");
ofstream fout("combinari.out");
int z[30];
int n,k;
void tiparit(){
int i;
for(i=1;i<=k;i++)
fout<<z[i]<<" ";
fout<<endl;
}
int merge(int c){
int i;
if(z[c]>z[c-1])return 1;
return 0;
}
void inapoi(int c){
int i;
if(c==k+1)tiparit();
else
for(i=1;i<=n;i++)
{
z[c]=i;
if(merge(c)) inapoi(c+1);
}
}
int main(){
z[0]=0;
fin>>n;
fin>>k;
inapoi(1);
}