以下是引用beyondyf在2013-12-10 14:35:24的发言:
呵呵既然韶志给了这么高的评价,那就参与一下
#include <stdio.h>
void cal(int n, int a, int b)
{
static int f[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
const int e[] = {1, 10, 100, 1000, 10000};
int t, i;
if(n == 5)
{
if(!(b % a) && (t = b / a) < 10)
printf("%d * %d = %d\n", a, t, b);
return;
}
for(i = n; i < 10; i++)
{
t = f[n]; f[n] = f; f = t;
cal(n + 1, a * 10 + f[n], b + f[n] * e[n]);
t = f[n]; f[n] = f; f = t;
}
}
int main()
{
cal(0, 0, 0);
return 0;
}
编程思想很重要
杨兄弟的代码
越是简洁 越是难以读懂