Sa se afiseze toate descompunerile unui numar in suma de cifre nenule distincte (partitiile numarului).
#include<iostream>Ordonate strict crescator
using namespace std;
int x[100],n;
int afisare(int n)
{int i;
for(i=1;i<=n;i++)
cout<<x[i]<<"+";
cout<<"\b ";
cout<<endl;}
int verif(int i)
{if(i>1 && x[i]<x[i-1])
return 0;
return 1;}
void back(int i,int s)
{int j;
for(j=1;j<=s;j++)
{x[i]=j;
if(x[i]==s)
afisare(i);
else back(i+1,s-x[i]);
}
}
int main()
{cin>>n;
back(1,n);
}
#include<iostream>Ordonate crescator (< sau =)
using namespace std;
int x[100]={0},n;
int afisare(int n)
{int i;
for(i=1;i<=n;i++)
cout<<x[i]<<"+";
cout<<"\b ";
cout<<endl;}
int verif(int i)
{if(i>1 && x[i]<x[i-1])
return 0;
return 1;}
void back(int i,int s)
{int j;
for(j=x[i-1]+1;j<=s;j++)
{x[i]=j;
if(x[i]==s)
afisare(i);
else back(i+1,s-x[i]);
}
}
int main()
{cin>>n;
back(1,n);
}
#include<iostream>
using namespace std;
int x[100]={0},n;
int afisare(int n)
{int i;
for(i=1;i<=n;i++)
cout<<x[i]<<"+";
cout<<"\b ";
cout<<endl;}
int verif(int i)
{if(i>1 && x[i]<x[i-1])
return 0;
return 1;}
void back(int i,int s)
{int j;
for(j=x[i-1];j<=s;j++)
{x[i]=j;
if(x[i]==s)
afisare(i);
else back(i+1,s-x[i]);
}
}
int main()
{cin>>n;
x[0]=1;
back(1,n);
}