Pagini recente » Cod sursa (job #1486655) | Cod sursa (job #1779475) | Cod sursa (job #619511) | Cod sursa (job #784962) | Cod sursa (job #810655)
Cod sursa(job #810655)
#include <iostream>
#include <fstream>
using namespace std;
int st[1000];
int n,p,contor=0;
fstream f("combinari.in",ios::in);
fstream g("combinari.out",ios::out);
void back(int k)
{
int i;
long long suma=0;
if(k==p+1)
{
for(i=1;i<=p;i++)
g<<st[i]<<" ";
g<<endl;
}
else
{
if(k>1) st[k]=st[k-1];
else st[k]=0;
while(st[k]<n-p+k)
{
st[k]++;
back(k+1);
}
}
}
int main()
{
f>>n>>p;
back(1);
return 0;
}