将0-9分别填入右面的方框中,(每个数字只能用一次),使竖式成立.( )+( )( )+( )( )( )=( )( )( )( )
#include<stdio.h>
void main()
{
int a1,a2,a3,a4,a5,a6,a7,a8,a9,a10;
for(a1=0;a1<10;a1++)
for(a2=0;a2<10;a2++)
if(a2!=a1)
for(a3=0;a3<10;a3++)
if(a3!=a2&&a3!=a1)
for(a4=0;a4<10;a4++)
if(a4!=a3&&a4!=a2&&a4!=a1)
for(a5=0;a5<10;a5++)
if(a5!=a4&&a5!=a3&&a5!=a2&&a5!=a1)
for(a6=0;a6<10;a6++)
if(a6!=a5&&a6!=a4&&a6!=a3&&a6!=a2&&a6!=a1)
for(a7=0;a7<10;a7++)
if(a7!=a6&&a7!=a5&&a7!=a4&&a7!=a3&&a7!=a2&&a7!=a1)
for(a8=0;a8<10;a8++)
if(a8!=a7&&a8!=a6&&a8!=a5&&a8!=a4&&a8!=a3&&a8!=a2&&a8!=a1)
for(a9=0;a9<10;a9++)
if(a9!=a8&&a9!=a7&&a9!=a6&&a9!=a5&&a9!=a4&&a9!=a3&&a9!=a2&&a9!=a1)
for(a10=0;a10<10;a10++)
if(a10!=a9&&a10!=a8&&a10!=a7&&a10!=a6&&a10!=a5&&a10!=a4&&a10!=a3&&a10!=a2&&a10!=a1)
if(a1+a2*10+a3+a4*100+a5*10+a6==a7*1000+a8*100+a9*10+a10)
printf("%d+%d%d+%d%d%d=%d%d%d%d\n",a1,a2,a3,a4,a5,a6,a7,a8,a9,a10);
}
结果
这是其中一种,好几个答案!那几个十位上的可以交换,各位也可以交换。
孩子已经算出得数了,相当于蒙出来的~~可是没有思路,您能写出解题过程么~?
行,首先,有三位数的相加,得到四位数,说明结果的千位肯定是1,因为即便999相加也得不出2000多;所以结果千位是1
再看结果的百位,1,2肯定不行,只能是0了
#include <stdio.h>
main()
{
int i[10];
for (i[0]=0;i[0]<=9;i[0]++){
for (i[1]=1;i[1]<=9;i[1]++){
if (i[1]==i[0]) continue;
for (i[2]=0;i[2]<=9;i[2]++){
if (i[2]==i[0] || i[2]==i[1])continue;
for (i[3]=1;i[3]<=9;i[3]++){
if (i[3]==i[0] || i[3]==i[1] || i[3]==i[2])continue;
for (i[4]=0;i[4]<=9;i[4]++){
if (i[4]==i[0] || i[4]==i[1] || i[4]==i[2] ||i[4]==i[3])continue;
for (i[5]=0;i[5]<=9;i[5]++){
if (i[5]==i[0] || i[5]==i[1] || i[5]==i[2] ||i[5]==i[3] ||i[5]==i[4])continue;
for (i[6]=1;i[6]<=9;i[6]++){
if (i[6]==i[0] || i[6]==i[1] || i[6]==i[2] ||i[6]==i[3] ||i[6]==i[4]||i[6]==i[5])continue;
for (i[7]=0;i[7]<=9;i[7]++){
if (i[7]==i[0] || i[7]==i[1] || i[7]==i[2] ||i[7]==i[3] ||i[7]==i[4]||i[7]==i[5]||i[7]==i[6])continue;
for (i[8]=0;i[8]<=9;i[8]++){
if (i[8]==i[0] || i[8]==i[1] || i[8]==i[2] ||i[8]==i[3] ||i[8]==i[4]||i[8]==i[5]||i[8]==i[6]||i[8]==i[7])continue;
for (i[9]=0;i[9]<=9;i[9]++){
if (i[9]==i[0] || i[9]==i[1] || i[9]==i[2] ||i[9]==i[3] ||i[9]==i[4]||i[9]==i[5]||i[9]==i[6]||i[9]==i[7]||i[9]==i[8])continue;
if ( i[0]+i[1]*10+i[2]+i[3]*100+i[4]*10+i[5] == i[6]*1000+i[7]*100+i[8]*10+i[9])printf ("(%d) (%d%d) (%d%d%d) (%d%d%d%d)\n",i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8],i[9]);
}}}}}}}}}
}
return 0;
}
(2) (46) (987) (1035)
(2) (47) (986) (1035)
(2) (64) (987) (1053)
(2) (67) (984) (1053)
(2) (84) (967) (1053)
(2) (86) (947) (1035)
(2) (87) (946) (1035)
(2) (87) (964) (1053)
(3) (45) (978) (1026)
(3) (48) (975) (1026)
(3) (74) (985) (1062)
(3) (75) (948) (1026)
(3) (75) (984) (1062)
(3) (78) (945) (1026)
(3) (84) (975) (1062)
(3) (85) (974) (1062)
(4) (35) (987) (1026)
(4) (37) (985) (1026)
(4) (62) (987) (1053)
(4) (67) (982) (1053)
(4) (73) (985) (1062)
(4) (75) (983) (1062)
(4) (82) (967) (1053)
(4) (83) (975) (1062)
(4) (85) (937) (1026)
(4) (85) (973) (1062)
(4) (87) (935) (1026)
(4) (87) (962) (1053)
(5) (34) (987) (1026)
(5) (37) (984) (1026)
(5) (43) (978) (1026)
(5) (48) (973) (1026)
(5) (73) (948) (1026)
(5) (73) (984) (1062)
(5) (74) (983) (1062)
(5) (78) (943) (1026)
(5) (83) (974) (1062)
(5) (84) (937) (1026)
(5) (84) (973) (1062)
(5) (87) (934) (1026)
(6) (42) (987) (1035)
(6) (47) (982) (1035)
(6) (82) (947) (1035)
(6) (87) (942) (1035)
(7) (34) (985) (1026)
(7) (35) (984) (1026)
(7) (42) (986) (1035)
(7) (46) (982) (1035)
(7) (62) (984) (1053)
(7) (64) (982) (1053)
(7) (82) (946) (1035)
(7) (82) (964) (1053)
(7) (84) (935) (1026)
(7) (84) (962) (1053)
(7) (85) (934) (1026)
(7) (86) (942) (1035)
(8) (43) (975) (1026)
(8) (45) (973) (1026)
(8) (73) (945) (1026)
(8) (75) (943) (1026)
7+34+985=1026