1: #include <stdio.h>
2:
3: int Reverse(int i)
4: {
5: int r = 0;
6: while (i)
7: {
8: r = r * 10 + i % 10;
9: i = i / 10;
10: }
11: return r;
12: }
13:
14: int fun(int i, int j)
15: {
16: int buf[4], k = 0;
17: while (i)
18: {
19: buf[k] = i % 10;
20: i = i / 10;
21: k++;
22: }
23:
24: if(buf[0]!=buf[1] && buf[0] != buf[2] && buf[0] != buf[3] && buf[0] != j)
25: if(buf[1] != buf[2] && buf[1]!= buf[3] && buf[1] != j)
26: if(buf[2] != buf[3] && buf[2] != j)
27: if(buf[3] != j)
28: return 1;
29:
30: return 0;
31: }
32:
33: int main()
34: {
35: int i,j;
36: for(i=1000; i<10000; i++)
37: for(j=1; j<10; j++)
38: if (i * j == Reverse(i) && fun(i, j))
39: {
40: printf("%d\n", i);
41: printf("* %d\n", j);
42: printf("----\n");
43: printf("%d\n\n", i * j);
44: }
45: return 0;
46: }