Bingway original works. for reprinting, please indicate the author and source. If two consecutive digits are not the same in decimal format, it is called "No-duplicated plural ". For example, 105, 164, and 198 are "not duplicated and plural", but 11, 100, and 122 are not. The following uses a long type (long-type number A) to return the smallest "no-duplicated number" greater than ". 1 Static Long Gnext ( Long A)
2 {
3 Long N = A;
4 Int [] = New Int [ 100 ];
5 Int CNT = 0 ; // Number of digits
6 While (N > 0 )
7 {
8 A [CNT ++ ] = ( Int ) (N % 10 );
9 N /= 10 ; // Enter several digits to execute several times
10 }
11 Long TMP = 0 ; // Store temporary values
12 For ( Int J = CNT - 1 ; J > = 0 ; J -- ) // Cyclic Value
13 {
14 TMP = TMP * 10 + A [J]; // High Value
15 If (A [J] = A [J + 1 ]) // Compare whether two numbers are equal
16 {
17 TMP = TMP + 1 ; // If the comparison result is equal, 1 is added.
18 }
19
20 }
21 If (CNT > 2 | TMP> 90 ) /// /The number of input digits is greater than two.
22 {
23 CNT = 1 ;
24 For ( Int I = CNT; I > 0 ; I -- )
25 {
26 If (A [I] = A [I - 1 ]) // Compare whether two numbers are equal
27 {
28 TMP = TMP + 1 ;
29 }
30 }
31 }
32 Return TMP;
33 }
34 Static Long Getnext ( Long A)
35 {
36 Return Gnext ( + 1 );
37 }
Call getnext (), which is very simple and will not be written.
Main function entry