Solution 1:
#include <iostream>
#include <cstdio>
using namespace std;
void result (int num, int &result_add, int &result_mul)
{
int i, j, K;
i = num/100; Hundred
j = num/10%; 10-bit
k = num%; Single-digit
Result_add = i + j + K; Decomposition of the number of digits added
result_mul *= i * j * k; Multiply
}
int main ()
{
int i, j, K;
int Result_add, Result_mul;
for (i = 123 I <=329; i++)
{
J = i * 2;
K = i * 3;
Result_add = 0;
Result_mul = 1;
Result (I, Result_add, Result_mul);
Result (J, Result_add, Result_mul);
Result (k, Result_add, Result_mul);
if (Result_add = = && Result_mul = = 362880)
printf ("%d%d%d\n", I, J, K);
}
return 0;
}
Solution 2:
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main (int argc, const char * argv[])
{
int n, I, J;
The char a[10];//array definition is larger than the actual for
(n = 123; n < n++)
{
sprintf (A, "%d", n * 1000000 + N * 2 * 1000 + n * 3); /save Abcdefghi to string A for
(j = 0, i = ' 1 '; I <= ' 9 '; MEMCHR (A, i++, 9) && J + +);//Compare 1 to 9, record with J. When the character array A does not have the I corresponding character, according to the short-circuit principle, J + + does not execute, after the loop, J will not be equal to 9
if (j = = 9)
{
printf ("%d%d%d \ n", N, N * 2, n * 3);
}
}
return 0;
}