我来玩玩。
程序代码:
#include <stdio.h> #define N 9 #define START 123 #define END 334 int func(int num_a, int num_d, int num_g); int main(int argc, char *argv[]) { int num_a, num_d, num_g; for(num_a = START; num_a < END; num_a++) { num_d = num_a << 1; num_g = num_a * 3; if( func(num_a, num_d, num_g) ) { printf("%d %d %d\n", num_a, num_d, num_g); } } return 0; } int func(int num_a, int num_d, int num_g) { int rec[N] = {0}; int index; while(1) { if(!num_a && !num_d && !num_g) { break; } else { rec[num_a%10 - 1]++; rec[num_d%10 - 1]++; rec[num_g%10 - 1]++; num_a /= 10; num_d /= 10; num_g /= 10; } } for(index = 0; index < N; index++) { if(rec[index] != 1) { return 0; } } return 1; }