Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
680 B
2
Indexable
Never

#include <bits/stdc++.h>

using namespace std;

int a, b, v[10];

void afisare(int k, int v[]){
    for(int i=1; i<=k; i++){
        cout<<v[i]<<" ";
    }
    cout<<endl;
}

bool isok(int k, int v[]){
    for(int i=1; i<=k-1; i++){
        if(v[i]==v[k]){
            return false;
        }
    }
    return true;
}

void backtracking(int v[], int k){
    for(int i=a; i<=b; i++){
        v[k]=i;
        if(isok(k, v)){
            if(k==b-a+1){
                afisare(k, v);
            }
            else{
                backtracking(v, k+1);
            }
        }
    }
}

void solve(){
    cin>>a>>b;
    backtracking(v, 1);
}

int main(){
   solve();
    return 0;
}