瞎做了第一道:
#include <stdio.h>
main ()
{int a,b,c,d,e,f,g,x,y,z;
long s;
clrscr ();
for (a=0;a<10;a++)
for (b=0;b<10;b++)
{if (b==a) continue;
for (c=0;c<10;c++)
{if (c==a||c==b) continue;
for (d=0;d<10;d++)
{if (d==a||d==b||d==c) continue;
for (e=0;e<10;e++)
{if (e==a||e==b||e==c||e==d) continue;
for (f=0;f<10;f++)
{if (f==a||f==b||f==c||f==d||f==e) continue;
for (g=0;g<10;g++)
{if (g==a||g==b||g==c||g==d||g==e||g==f) continue;
for (x=0;x<10;x++)
{if (x==a||x==b||x==c||x==d||x==e||x==f||x==g) continue;
for (y=0;y<10;y++)
{if (y==a||y==b||y==c||y==d||y==e||y==f||y==g||y==x) continue;
{z=45-a-b-c-d-e-f-g-x-y;
{s=(b*10000+c*1000+d*100+e*10+2*(d*100+f*10+g));
if (s==x*10000+y*1000+z*100+d*10+e) goto tt;
}
}
}
}
}
}
}
}
}
}
tt: printf(" A B C D E\n");
printf(" D F G\n");
printf(" + D F G\n");
printf("-----------\n");
printf(" X Y Z D E\n");
printf("\n");
printf("%2d%2d%2d%2d%2d\n",a,b,c,d,e);
printf(" %2d%2d%2d\n",d,f,g);
printf(" + %2d%2d%2d\n",d,f,g);
printf("-----------\n");
printf("%2d%2d%2d%2d%2d\n",x,y,z,d,e);
printf("\n");
printf("a =%2d,b =%2d,c =%2d,d =%2d,e =%2d,f =%2d,g =%2d,x =%2d,y =%2d,z=% 2d\n",a,b,c,d,e,f,g,x,y,z);
getch ();
}