解题思路:
就是这么暴力。
参考代码 ① :
#include<bits/stdc++.h> using namespace std; bool arr[10]; void Judge(int mul, int i2) { int i1 = mul / i2, pos = 0, index; if (mul > 9876) return; char mulc[5], i1c[5], i2c[5]; sprintf(mulc, "%d", mul); sprintf(i1c, "%d", i1); sprintf(i2c, "%d", i2); while (mulc[pos]) { arr[mulc[pos++] - '0'] = true; } pos = 0; while (i1c[pos]) { index = i1c[pos++] - '0'; if (arr[index]) return; arr[index] = true; } pos = 0; while (i2c[pos]) { index = i2c[pos++] - '0'; if (arr[index]) return; arr[index] = true; } for (int i = 1; i < 10; i++) if (!arr[i]) return; printf("%s = %s x %s\n", mulc, i2c, i1c); } int main() { for (int mul = 1; mul < 9283; mul++) for (int i = 1; i < 101; i++) { if (mul%i != 0) continue; Judge(mul, i); memset(arr, 0, 10); } }
参考代码 ② :
#include<iostream> /* > _ < */ int main() { char Ans[][20] = { "4396 = 28 x 157", "5346 = 18 x 297", "5346 = 27 x 198", "5796 = 12 x 483", "5796 = 42 x 138", "6952 = 4 x 1738", "7254 = 39 x 186", "7632 = 48 x 159", "7852 = 4 x 1963", "" }; int index = 0; while (Ans[index][0]) puts(Ans[index++]); }
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题9.2 (Java代码)浏览:608 |
C语言考试练习题_保留字母 (C语言代码)浏览:700 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:901 |
循环入门练习5 (C语言代码)浏览:829 |
C二级辅导-阶乘数列 (C语言代码)浏览:508 |
Quadratic Equation (C语言代码)浏览:988 |
上车人数 (C语言代码)浏览:710 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:454 |
陶陶摘苹果2 (C++代码)浏览:537 |
C语言程序设计教程(第三版)课后习题6.7 (C语言代码)浏览:502 |