Pagini recente » Cod sursa (job #1803887) | Cod sursa (job #3291551) | Cod sursa (job #2298208) | Cod sursa (job #3182854) | Cod sursa (job #3244390)
#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;
}