Cod sursa(job #567251)
| Utilizator | Data | 29 martie 2011 21:38:26 | |
|---|---|---|---|
| Problema | Combinari | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.41 kb |
#include<fstream>
using namespace std;
int sol[19];
int main()
{int n,k,i,ok=1,t,j;
ifstream f1("combinari.in");
ofstream f2("combinari.out");
f1>>n>>k;
for(i=1;i<=k;i++)
sol[i]=i;
while(ok)
{for(t=1;t<=k;t++)
f2<<sol[t]<<" ";
f2<<'\n';
i=k;
while((i>0)&&(sol[i]==n-k+i)) i--;
if(!i) break;
else
{sol[i]++;
for(j=i+1;j<=k;j++)
sol[j]=sol[j-1]+1;
}
}
return 0;
}
