见注释。。。。。。
(C语言)
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main()
{
char s[20],buf[100];
int abc,de;
int count = 0,is_shushi,i;
int x,y,z;
scanf("%s",s);
for(abc = 111;abc <= 999;abc++)
for(de = 11;de <= 99;de++)
{
x = abc*(de%10);//x = abc*e
y = abc*(de/10);//x = abc*d
z = abc*de;
sprintf(buf,"%d%d%d%d%d",abc,de,x,y,z);
/*sprintf函数打印到字符串中,可以将多个字符串连接成字符串,
eg:
char str[20];
char s1={'A','B','C'};
char s2={'T','Y','x'};
sprintf(str,"%.3s%.3s",s1,s2);
*/
is_shushi = 1;
for(i = 0;i < strlen(buf);i++)
{
if(strchr(s,buf[i]) == NULL)
is_shushi = 0;
/*
1.函数原型:extern char *strchr(const char *s,char c);
2.函数功能:查找字符串s中 第一次 出现字符c的位置。
3.返回说明:返回指向第一次出现字符character位置的指针,如果没找到则返回NULL。
*/
}
if(is_shushi)
{
printf("<%d>\n",++count);
printf("%5d\nx%4d\n-----\n%5d\n%4d\n-----\n%5d\n\n",abc,de,x,y,z);
}
}
printf("The number of solution = %d\n",count);
return 0;
}