Cod sursa(job #3244390)
| Utilizator | Data | 24 septembrie 2024 17:32:11 | |
|---|---|---|---|
| Problema | Combinari | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.65 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("combinari.in");
ofstream fout("combinari.out");
int st[20],n,m;
void Afis(int top)
{
for(int i=1; i<=top; i++)
fout<<st[i]<<" ";
fout<<"\n";
}
void Back()
{
int top,cand;
top=1;
st[top]=0;
while(top)
{
cand=0;
while(!cand&&st[top]<n)
{
st[top]++;
cand=1;
}
if(cand==0) top--;
else if(top==m) Afis(top);
else
{
top++;
st[top]=st[top-1];
}
}
}
int main()
{
fin>>n>>m;
Back();
return 0;
}
