C:
# Include <stdio. h>
Bool check (int A []); // puts the number of nine into an array, and checks whether there are the same number through double loop.
Int main (void)
{
Int A [9], I, j, flag = 1;
Int x, y, z;
For (I = 123; I <329; I ++) // the minimum value of X is 123, and the maximum value cannot be 329.
{
X = I;
Y = 2 * I;
Z = 3 * I;
A [0] = x/0/100;
A [1] = (X/10) % 10;
A [2] = x % 10;
A [3] = y/100;
A [4] = (y/10) % 10;
A [5] = Y % 10;
A [6] = z/100;
A [7] = (z/10) % 10;
A [8] = z % 10;
For (j = 0; j <9; j ++)
{
If (A [J] = 0)
Flag = 0;
} // Prevent the second digit from being 0 (when the third digit is 0, there must be repeated digits if the third digit is doubled)
If (flag = 0)
{
Flag = 1;
Continue;
} // When the second number is 0, continue to the next number.
If (check (A) = true)
{
Int I;
For (I = 0; I <9; I ++)
Printf ("% d", a [I]);
Printf ("\ n ");
}
}
}
Bool check (int A [])
{
Int I, J;
For (I = 0; I <9; I ++)
For (j = I + 1; j <= 9; j ++)
{
If (A [I] = A [J])
Return false;
}
Return true;
}
C ++:
# Include <iostream>
Using namespace STD;
Int main ()
{
Int I, x, y, z;
Int d [9] = {1, 2, 3, 4, 5, 6, 7, 8, 9 };
Do {
X = d [0] * 100 + d [1] * 10 + d [2];
Y = d [3] * 100 + d [4] * 10 + d [5];
Z = d [6] * 100 + d [7] * 10 + d [8];
If (y = x * 2 & Z = x * 3)
Cout <x <Y <z <Endl;
} While (next_permutation (D, D + 9 ));
Return 0;
}
Next_permutation is an arrangement function, and 9 is the length of the arrangement.
1-9, divided into three digits, the ratio is