Pagini recente » Cod sursa (job #3251447) | Cod sursa (job #2819008) | Cod sursa (job #2964559) | Cod sursa (job #99870) | Cod sursa (job #2203452)
#include<iostream>
#include<fstream>
using namespace std;
ifstream fin("partitiinumar.in");
ofstream fout("partitiinumar.out");
int n,x[1001],nr,ok;
void tipar(int k){
ok=1;
for(int i=1;i<=k;i++)
fout<<x[i]<<" ";
fout<<'\n';
}
int cont(int k){
if(k>1&&x[k]-x[k-1]<=1)
return 0;
return 1;
}
void bkt(int k){
for(int i=x[k-1]+1;i<=n;i++)
{
x[k]=i;
if(cont(k)==1){
tipar(k);
if(k<n)
bkt(k+1);
}
}
}
int main(){
fin>>n;
ok=0;
bkt(1);
if(ok==0)
fout<<"fara solutie";
return 0;
}