Untitled

 avatar
unknown
c_cpp
4 years ago
640 B
12
Indexable
#include <iostream>

using namespace std;

bool checkDistinct(int n){

    int arr[4];

    for(int i=0;i<4;i++){

        arr[i] = n%10;
        n /= 10;
    }

    for(int i=0;i<4;i++){

        for(int j=i+1;j<4;j++){

            if(arr[i]==arr[j]){
                return false;
            }

        }

    }

    return true;
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int n;

    cin >> n;

    for(int i=n+1;i<=9000;i++){

        if(checkDistinct(i)==true){
            cout << i << endl;
            return 0;
        }

    }
    return 0;
}

Editor is loading...