将1-9填进算式中()()()()*()=()()()()
问题描述:
将1-9填进算式中()()()()*()=()()()()
()()()()*()=()()()() 九个数字不能重复使用,一个数字只能用一次
( )( )( )( 3 ) 剩余1.5.6.7.8.9这六个数分别填进算式中,使算式成立
*( 4 )
-----------------
( )( )( )( 2 )
答
haha...有意思.答案居然是唯一的.
1963*4 = 7852
#include
#include
#include
int main(void)
{
int i,k;
char str1[5];
char str2[5];
intn[10];
for (k=0; k{
i = k*10+3;
int res = i*4;
if (res >= 10000)
break;
if (res-res/10*10 == 2)
{
sprintf(str1, "%04d", i);
sprintf(str2, "%04d", res);
for (int j=1; jn[j] = 0;
n[4] = 1;
for (int j=0; j
for (int j=0; j
bool flag = true;
for (int j=1; jif (n[j] != 1)
{
flag = false;
break;
}
if (flag)
printf("%04d %04d success\n", i, res);
//else
//printf("%04d %04d fail\n", i, res);
}
}
system("PAUSE");
return 0;
}