Cod sursa(job #897419)
| Utilizator | Data | 27 februarie 2013 20:27:38 | |
|---|---|---|---|
| Problema | Combinari | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <fstream>
using namespace std;
ifstream f("permutari.in");
ofstream g("permutari.out");
int k,n,i,v[100],m;
bool ok;
void tipar(int k) {
for (i=1;i<=m;i++) { g<<v[i]<<" ";};
g<<"\n";
}
int main () {
f>>n>>m;k=1;v[k]=0;
while (k!=0) { ok=false;
while ((v[k]<n) && (ok==false)){v[k]=v[k]+1;ok=true;};
if (ok==false) k--;
else if (k==m) tipar(k);
else {k++;v[k]=v[k-1];}
}
}
