排序(permutation)

#include<stdio.h>
int temp1,temp2,temp3,a,b,c,d,e,f,g,h,i;


int check1()
{
   if(c==a||c==b)
        return 0;
   return 1;
}
int check2()
{
 if(d==a||d==b||d==c||e==a||e==b||e==c||f==a||f==b||f==c||d==e||d==f||e==f)
    return 0;
 return 1;
}
int check3()
{
    if(g==a||g==b||g==c||g==d||g==e||g==f||g==h||g==i||h==a||h==b||h==c||h==d||h==e||h==f||h==i||i==a||i==b||i==c||i==d||i==e||i==f)
        return 0;
    return 1;
}
int main()
{
    for(a=1;a<=3;a++)
        for(b=1;b<=9;b++)
        {
         if(a!=b)
         {
         for(c=1;c<=9;c++)
          {
          if(check1())
           {
             temp1=a*100+b*10+c;
             temp2=2*temp1;
             d=temp2/100;
             f=temp2%10;
             e=(temp2-d*100-f)/10;
             if(check2()&&d&&e&&f)
              {
              temp3=3*temp1;
              g=temp3/100;
              i=temp3%10;
              h=(temp3-g*100-i)/10;
             if(check3()&&g&&h&&i&&temp3<=987)
             printf("%d %d %d\n",temp1,temp2,temp3);  // 运用了一下输出中间变量来检查出错的地方
              }
           }
          }
         }
        }
        return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值