乘式还原

 

 

  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 }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值