1 #include <stdio.h>
2
3 void print(long a, long b, long s1, long s2, long s3);
4
5 int jud(long q, char *pflag);
6
7 int main()
8 {
9 long i, j, k, l, m, n, term, t1, t2, t3;
10 int flag;
11 for (i = 0; i <= 4; ++i)
12 {
13 for (j = 5; j <= 9; ++j)
14 {
15 for (k = 0; k <= 4; ++k)
16 {
17 term = 100 * i + 10 * j + k;
18
19 for (flag = 0 , n = 0; n < 4 && !flag; )
20 {
21 flag = jud((t3 = ++n * 100 * term) / 100, "001");
22 }
23
24 if(flag)
25 {
26 for (flag = 0, m = 0; m < 4 && !flag; )
27 {
28 flag = jud((t2 = ++m * 10 * term) / 10, "1100");
29 }
30
31 if(flag)
32 {
33 for (flag = 0, l = 5; l < 9&& !flag;)
34 {
35 flag = jud(t1 = ++l * term, "0000");
36 }
37
38 if(flag && jud(t1 + t2 + t3, "00101"))
39 {
40 print(term, n * 100 + m * 10 + l, t1, t2, t3);
41 }
42 }
43 }
44 }
45 }
46 }
47 }
48
49 void print(long a, long b, long s1, long s2, long s3)
50 {
51 printf("\n %ld\n", a);
52 printf("*) %ld\n", b);
53 printf("………………….\n");
54 printf(" %ld\n %ld\n %ld\n", s1, s2 / 10, s3 / 100);
55 printf("………………….\n");
56 printf(" %ld\n", a * b);
57 }
58 int jud(long q, char *pflag)
59 {
60 while(q != 0 && *pflag != NULL)
61 {
62 if(*pflag - '0' != (q % 10 >= 5 ? 1 : 0))
63 {
64 return 0;
65 }
66
67 else
68 {
69 q /= 10;
70 ++pflag;
71 }
72 }
73
74 if(q == 0 && *pflag == NULL)
75 {
76 return 1;
77 }
78
79 else
80 {
81 return 0;
82 }
83
84 }