I am solving the question "Beautiful Years" [271 A]. I tried different approach but not able to get the answer.

Revision en1, by rohansoni649, 2020-11-25 17:04:52

include <bits/stdc++.h>

using namespace std;

int beautiful_year(int y) { int flag=0,i=0,digit[10],j=0; while(y) { digit[i++]=y%10; y=y/10; } int size=sizeof(digit)/sizeof(digit[0]); for(i=0;i<size;i++) { for(j=i;j<size;j++) { if(digit[i]==digit[j]) return 0; else flag=1;
} } if(flag==1) return 1; else return 0; } int main() { int year; cin>>year; year++; while(year) { if(beautiful_year(year)) { cout<<year; break; } year++; } return 0; }

Tags #c++

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English rohansoni649 2020-11-25 17:04:52 834 I searched a solution on google but was trying with different approach (published)