Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int a, b, c, d;
while(true){
n++;
a = n/1000;
b = n / 100 % 10;
c = n/10 % 10;
d = n%10;
if(a != b && a != c && a != d && b != c && b != d && c != d){
break;
}
}
cout<<n;
return 0;
}
Copy The Code &
Try With Live Editor
Input
1987
Output
2013
Demonstration
Codeforcess Solution 271-A A. Beautiful Year ,C++, Java, Js and Python,271-A,Codeforcess Solution