Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int st[10],k,n,v;
- int nrtoc(int nr){
- }
- void init(){
- n=6;
- v=3;
- st[k]=0;
- }
- int succesor(){
- if(st[k]<n){
- st[k]++;
- return 1;
- }
- return 0;
- }
- int valid(){
- int i;
- for(i=0;i<k;i++)
- if(st[i]==st[k]) return 0;
- if(k==v && !(st[2]==2 || st[2]==5)) return 0;
- return 1;
- }
- int solutie(){
- return k==v;
- }
- void tipar(){
- for(int i=1;i<=v;i++)cout<<st[i]<<" ";
- cout<<endl;
- }
- void bkt(){
- int as;
- k=1;
- init();
- while(k>=0){
- do{}while((as=succesor())&&!valid());
- if(as)
- if(solutie()) tipar();
- else{
- k++;
- init();
- }
- else k--;
- }
- }
- int main(){
- bkt();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement