将a b c依次试探每一个可能解,约束条件是满足等式关系(abb)*b=acbc;
a(1-----9) b(2------9) c(0-----9)
#include<stdio.h>
int main(){
int a,b,c,temp1,temp2,flag=0;
for(a=1;a<=9;a++)
for(b=2;b<=9;b++)
for(c=0;c<=8;c++){ //三层for循环形成暴力搜索,试探每一个数的所有解
temp1=a*100+b*10+b;
temp2=a*1000+c*100+b*10+c;
if(temp1*b==temp2){
printf("%d\n%d\n%d\n",a,b,c);
printf("%d*%d=%d\n",temp1,b,temp2);
flag=1;
}
}
if(flag==0)
printf("no result");
return 0;
}