28 lines
768 B
C++
28 lines
768 B
C++
#include<bits/stdc++.h>
|
||
using namespace std;
|
||
int main()
|
||
{
|
||
int i, ok, abc, de, x, y, z, count = 0;
|
||
char s[11], buf[50];
|
||
scanf("%s", s);
|
||
for(abc = 111; abc <= 999; abc++)
|
||
for(de = 11; de <= 99; de++)
|
||
{
|
||
x = abc*(de%10); y = abc*(de/10); z = abc*de;
|
||
sprintf(buf, "%d%d%d%d%d", abc, de, x, y, z);//将产生的所有数字存入缓冲区。
|
||
ok = 1;
|
||
for(i = 0; i<strlen(buf) && ok==1; i++)
|
||
if(strchr(s, buf[i]) == NULL) ok = 0;//将缓冲区的每一个数字与输入的数字序列比较,若不存在,则strchr返回NULL。
|
||
if(ok)//若经计算产生的数字均合法,则输出竖式。
|
||
{
|
||
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 solutions = %d\n", count);
|
||
return 0;
|
||
}
|
||
|
||
|
||
|