
1条回答 默认 最新
threenewbee 2020-02-04 19:06关注分别把三个数字填充到0-9的数组中,然后判断1-9是否都是1。
// Q1053340.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <stdio.h> #include <string.h> int judge(int n) { int arr[10]; memset(arr, 0, sizeof(int) * 10); for (int i = 1; i < 4; i++) { int n1 = n * i; for (int j = 0; j < 3; j++) { arr[n1 % 10] = 1; n1 /= 10; } } for (int i = 1; i < 10; i++) if (!arr[i]) return 0; return 1; } int main() { for (int i = 123; i <= 987; i++) if (judge(i)) printf("%d %d %d\n", i, i *2, i * 3); return 0; }192 384 576
219 438 657
273 546 819
327 654 981
Press any key to continue . . .本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报