Cod sursa(job #903355)
Utilizator | Isaila Ioan Andrei Iandrei96 | Data | 1 martie 2013 20:12:36 |
---|---|---|---|
Problema | Submultimi | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.51 kb |
#include <fstream>
using namespace std;
ifstream f("submultimi.in");
ofstream g("submultimi.out");
int k,n,i,v[100],m;
bool ok;
void tipar(int k) {
for (i=1;i<=k;i++) { g<<v[i]<<" ";};
g<<"\n";
}
int main () {
f>>n;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<=n) tipar(k);
if((ok==true)&&(k<n)){k++;v[k]=v[k-1];}
}
}