Documente Academic
Documente Profesional
Documente Cultură
int ebun (int k) {int i; for(i=1; i<k; i++) if(st[i]==st[k]) return 0; return 1; }
void back(int k) {int i; for(i=1; i<=n; i++){ st[k]=i; if(ebun(k)) if(esol(k)) afis(k); else back(k+1); } }
void back (int k) {int i; for(i=1; i<=n; i++){ st[k]=i; if(ebun(k)) if(esol(k)) afis(k); else back(k+1); } }
PERMUTRI
#include<iostream.h> #include<fstream.h> int st[20], n;
int ebun (int k) {int i; for(i=1; i<k; i++) if(st[i]==st[k]) return 0; return 1; }
void back (int k) {int i; for(i=1; i<=n; i++){ st[k]=i; if(ebun(k)) if(esol(k)) afis(k); else back(k+1); } }
PRODUS CARTEZIAN
void back (int k) {int i; for(i=1; i<=n; i++){ st[k]=i; if(ebun(k)) if(esol(k)) afis(k); else back(k+1); } }
int afis(int k) {int i; cout<<{; for(i=1; i<=k; i++) if (st[i]==1) cout<<i; cout<<\b}; cout<<endl; }
void back (int k) {int i; for(i=0; i<=1; i++){ st[k]=i; if(ebun(k)) if(esol(k)) afis(k); else back(k+1); } }