Cod sursa(job #1411219)
Utilizator | Data | 31 martie 2015 15:47:53 | |
---|---|---|---|
Problema | Combinari | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.47 kb |
#include <fstream>
using namespace std;
ifstream fi ("combinari.in");
ofstream fo ("combinari.out");
int i,n,k,a[100],j;
bool dif;
int main()
{
fi>>n>>k;
i=1;
while(i>0)
{
if(i==k+1)
{
for(j=1; j<=k; j++)
fo<<a[j]<<' ';
fo<<'\n';
i--;
}
else
{
if(a[i]<n)
{
a[i]++;
i++;
a[i]=a[i-1];
}
else
{
a[i]=0;
i--;
}
}
}
}