Pagini recente » Statistici Man Mihai (Mishutheman) | Rating Hercule (Hercule) | Statistici Sbaroi Ionut-Alexandru (7MoOdY) | Rating Buciu Emilian (Emi09) | Cod sursa (job #1107579)
#include <fstream>
#define NMAX 20
using namespace std;
ifstream fin("combin.in");
ofstream fout("combin.out");
int e[NMAX],res[NMAX];
int main()
{
int i,n,m,ok=0;
fin>>n>>m;
for(i=1; i<=m; i++)
res[i]=i;
while(!ok)
{
for(i=1; i<=m; i++)
fout<<res[i]<<" ";
fout<<'\n';
i=m;
while(res[i]==n-m+i&&i>=0)
i--;
if(i==0) ok=1;
else
{
res[i]++;
for(int k=i+1; k<=n; k++)
res[k]=res[i]+k-i;
}
}
return 0;
}