竞赛入门经典 3.2竖式问题

#include<stdio.h>

#include<string.h>
int main()
{
int count=0;
char s[20],buff[99];
scanf("%s",s);
for(int abc=111;abc<=999;abc++)
{
for(int de=11;de<=99;de++)
{
int x=abc*(de%10),y=abc*(de/10),z=abc*de;
sprintf(buff,"%d%d%d%d%d",abc,de,x,y,z);
int ok=1;
for(int i=0;i<strlen(buff);i++)
if(strchr(s,buff[i])==NULL) ok=0;
if(ok)
{
printf("<%d> ",++count);
printf("%5d X%4d ----- %5d %4d ----- %5d ",abc,de,x,y,z);
}


}
}

printf("The number of solutions = %d ",count);
return 0;

}

原文地址:https://www.cnblogs.com/is-Tina/p/7274649.html