A simple analysis of the topic can be found:
- The first number is 123 minimum
- The first number up to 333, and then a big third number is the four-digit
So you can do this:
1 for(int a=100;a<=333;a++){ 2 b=2*a; 3 c=3*a 4 ... 5 }
Then we can separate each digit of each number came out, along with the tag inside the array:
1 while(a!=0){ 2 flag[a%10]=1; 3 a/=10; 4 }
code:
. 1 #include <bits / STDC ++ H.> // universal header 2 the using namespace STD; . 3 BOOL In Flag [ 15 ]; // tag array . 4 void F ( int A) { // void space type, no value is returned . 5 the while (! a = 0 ) { // decomposition of the digits . 6 in Flag [% a 10 ] = . 1 ; . 7 a / = 10 ; . 8 } . 9 10 / * . 11 I originally written, this is also the line, I recommend that the above personally 12 13 is In Flag [A% 10] =. 1; 14 In Flag [A% 100-A% 10] =. 1; 15 In Flag [A / 100] =. 1; 16 * / . 17 return ; 18 is } . 19 int main () { 20 is int A, B, C; 21 is BOOL X = 0 ; 22 is for (A = 123 ; A <= 333 ; A ++) { // enumeration A 23 is X = 0 ; 24 B = A * 2 ; 25 C = A * . 3 ; 26 // generate another number two 27 F (A); F (B); F (C); // call the function 28 29 for ( int I = . 1 ; I <= . 9 ; I ++ ) { 30 IF (! In Flag [I] = . 1 ) { 31 is X = 0 ; 32 BREAK ; // out of the loop 33 is } 34 is } 35 36 IF (X) COUT << << A ' ' << << B ' ' << C << endl; // output 37 [ Memset (In Flag, 0 , 10); // reset flag array 10 may be changed to the sizeof (In Flag) 38 is } 39 return 0 ; 40 }
In addition, in order to prevent duplication, I quietly left a small mistake in the code, can be submitted directly, to see your friends!
PS: If you find an error, you can directly take away the code