2011年蓝桥杯高职,看下面的算式:□□ x □□ = □□ x □□□它表示:两个两位数相乘等于一个两位数乘以一个三位数.如果没有限定条件,这样的例子很多.但目前的限定是:这9个方块,表示1~9

来源:学生作业帮助网 编辑:作业帮 时间:2024/03/29 16:50:45
2011年蓝桥杯高职,看下面的算式:□□ x □□ = □□ x □□□它表示:两个两位数相乘等于一个两位数乘以一个三位数.如果没有限定条件,这样的例子很多.但目前的限定是:这9个方块,表示1~9

2011年蓝桥杯高职,看下面的算式:□□ x □□ = □□ x □□□它表示:两个两位数相乘等于一个两位数乘以一个三位数.如果没有限定条件,这样的例子很多.但目前的限定是:这9个方块,表示1~9
2011年蓝桥杯高职,
看下面的算式:
□□ x □□ = □□ x □□□
它表示:两个两位数相乘等于一个两位数乘以一个三位数.
如果没有限定条件,这样的例子很多.
但目前的限定是:这9个方块,表示1~9的9个数字,不包含0.
该算式中1至9的每个数字出现且只出现一次!
比如:
46 x 79 = 23 x 158
54 x 69 = 27 x 138
54 x 93 = 27 x 186
.
请编程,输出所有可能的情况!
注意:
左边的两个乘数交换算同一方案,不要重复输出!
不同方案的输出顺序不重要
#include
int check(int a,int b,int c,int d,int e,int f,int g,int h,int i)
{
if((a!=b)&&(a!=c)&&(a!=d)&&(a!=e)&&(a!=f)&&(a!=g)&&(a!=h)&&(a!=i))
{
if((b!=c)&&(b!=d)&&(b!=e)&&(b!=f)&&(b!=g)&&(b!=h)&&(b!=i))
{
if((c!=d)&&(c!=e)&&(c!=f)&&(c!=g)&&(c!=h)&&(c!=i))
{
if((d!=e)&&(d!=f)&&(d!=g)&&(d!=h)&&(d!=i))
{
if((f!=e)&&(f!=g)&&(f!=h)&&(f!=i))
{
if((e!=g)&&(e!=h)&&(e!=i))
{
if((g!=h)&&(g!=i))
{
if(h!=i)
return 1;
}
}
}
}
}
}
}
return 0;
}
void main()
{
//int j=0;
int a,b,c,d,e,f,g,h,i;
//int A[9],B[9],C[9],D[9],E[9],F[9],G[9],H[9],I[9];
for(a=1;a

2011年蓝桥杯高职,看下面的算式:□□ x □□ = □□ x □□□它表示:两个两位数相乘等于一个两位数乘以一个三位数.如果没有限定条件,这样的例子很多.但目前的限定是:这9个方块,表示1~9

原来是参加蓝桥的啊.

我是本B组的.

 【你的问题】

1)你循环的时候条件

a<=9,b<=9

你全部没了=!

2)

没有判断是否重复,应该用数组记录一下已经存在的两个数交换的情况


你本可以不用这么麻烦的.

用四个变量记录数据,一个数组记录出现次数就可以了.

你自己的我在给你看,可能需要花一点时间.

#include<stdio.h>

#include<string.h>

#include<stdlib.h>

int main()

{int temp;

int flag=0;

 bool shuzi[10]={0};

 char a[4];

 for(int i=10;i<99;i++)

  for(int j=0;j<99;j++)

   for(int k=0;j<99;j++)

    for(int t=100;t<999;t++)

    {

     flag=0;

     itoa(i,a,10);

     for(temp=0;temp<=strlen(a);temp++)

      shuzi[a[temp]-'0']=true;

     itoa(j,a,10);

     for(temp=0;temp<=strlen(a);temp++)

      shuzi[a[temp]-'0']=true;

     itoa(k,a,10);

     for(temp=0;temp<=strlen(a);temp++)

      shuzi[a[temp]-'0']=true;

     itoa(t,a,10);

     for(temp=0;temp<=strlen(a);temp++)

      shuzi[a[temp]-'0']=true;

     for(temp=1;temp<=9;temp++)

      if(!a[temp])

      {

       flag=true;

       break;     

      }

      if(!flag)

       printf("%d*%d=%d*%d\n",i,j,k,t);

      flag=0;

      memset(shuzi,0,sizeof(bool)*10);

    }

 return 0;

}