PERMUTARI
ARANJAMENTE
COMBINARI
#include using namespace std; int n,s[100]; int verif (int i, int j) { int k; for(k=1;kn) { for(k=1;k<=n;k++) cout<<s[k]<<" "; cout<<endl; } else { for(j=1;j<=n;j++) if(verif(i,j)) { s[i]=j; permutari(i+1); } } } int main() { cin>>n; permutari(1); return 0; }
#include using namespace std; int n,m,s[100]; int verif (int i, int j) { int k; for(k=1;km) { for(k=1;k<=m;k++) cout<<s[k]<<" "; cout<<endl; } else { for(j=1;j<=n;j++) if(verif(i,j)) { s[i]=j; aranjamente(i+1); } } } int main() { cin>>n>>m; aranjamente(1); return 0; }
#include using namespace std; int n,m,s[100]; void combinari (int i) { int k,j; if(i>m) { for(k=1;k<=m;k++) cout<<s[k]<<" "; cout<<endl; } else { for(j=s[i-1]+1;j<=n;j++) { s[i]=j; combinari(i+1); } } } int main() { cin>>n>>m; combinari(1); return 0; }
SUBMULTIMI #include using namespace std; int n,s[20]; void submultimi (int i) { int k,j; for(j=s[i-1]+1;j<=n;j++) { s[i]=j; for(k=1;k<=i;k++) cout<<s[k]<<" "; cout<<endl; submultimi(i+1); } } int main() { cin>>n; submultimi(1); return 0; } Exemplu: *date de intrare n=3 *date de iesire 1 12 123 13 2 23 3