#include<iostream>
#include<string.h>
using namespace std;
int main(){
int count=0;
char s[20],buf[90];
scanf("%s",s);
for(int i=111;i<=999;i++){
for(int j=11;j<=99;j++){
int x=i*(j%10),y=i*(j/10),z=i*j;
sprintf(buf,"%d%d%d%d%d",x,y,z,i,j);
int ok=1;
for(int k=0;k<strlen(buf);k++){
if(strchr(s,buf[k])==NULL){
ok=0;
break;
}
}
if(ok){
printf("<%d>\n",++count);
printf("%5d\nX%4d\n-----\n%5d\n%4d\n-----\n%5d\n\n",i,j,x,y,z);
}
}
}
printf("%d\n",count);
}
sprintf是将其他数字读入到字符数组当中。
strchr函数是用作在字符串中查找某字符,若查找不到返回NULL。
用法如上