Cod sursa(job #714521)
| Utilizator | Data | 15 martie 2012 20:08:52 | |
|---|---|---|---|
| Problema | Combinari | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.39 kb |
#include <fstream>
using namespace std;
ifstream in("combinari.in");
ofstream out("combinari.out");
int n,j,st[19];
void tipar (int k)
{
for(int i=1;i<=k;i++)
out<<st[i]<<" ";
out<<"\n";
}
void back(int k)
{
for(int i=st[k-1]+1;i<=n;i++)
{
st[k]=i;
if(k==j)
tipar(k);
else
back(k+1);
}
}
int main ()
{
in>>n>>j;
back(1);
in.close();
out.close();
}