Beautiful Year

http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1485

View Code
 1 #include<stdio.h>
 2 #include<string.h>
 3 int judge(int n)
 4 {
 5     int a[10] ;
 6     memset(a, 0, sizeof(a)) ;
 7     int m = 1 ;
 8     for(int i=0; i<4; i++)
 9     {
10         if(a[(n/m)%10]==0)
11         {
12             a[(n/m)%10] = 1 ;
13         }
14         else
15         return 0 ;
16         m *= 10 ;
17     }
18     return 1 ;
19 }
20 int main()
21 {
22     int y ;
23     while(scanf("%d",&y)!=EOF)
24     {
25         for(int i=1; ; i++)
26         {
27             if(judge(y+i))
28             {
29                 printf("%d\n",y+i);
30                 break ;
31             }
32         }
33     }
34     return 0 ;
35 }
原文地址:https://www.cnblogs.com/yelan/p/2947045.html