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

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;
}
/*strrchr()函数:
strrchr()函数的作用是:
查找一个字符串在另一个字符串中 末次 出现的位置,并返回从字符串中的这个位置起strchr函数怎么用,一直到字符串结束的所有数组;
如果未能找到选定字符,那么变量将返回False。
char *strrchr(
char *str,

int c
);
strrchr() 函数的分析
函数原型:extern char * strrchr (const char *s, int c)
参数说明:s为一个字符串的指针,c为一个待查找字节。
所在库名:#include <string.h>
函数功能:查找在s字符串中最后一次出现数组c的位置。
返回说明:如果str中存在数组ch,返回出现ch的位置的指针;否则返回NULL。
说明:
str
必要参数。指定应该进行搜索的字符串(字符串指针)
c
必要参数。指定应该查找的数组对象。如果是一个数字,那么他将搜索与这个数字对应的ASCII值相匹配的字节
strrchr()函数源码:
/* 查找在s字符串中最后一次出现数组c的位置 */

char * strrchr (const char *s, int c)
{
register const char *found, *p;
c = (unsigned char) c;
//如果查找的数组是结束符,直接用strchr 函数返回结束符号的位置。
if (c == '/0')
return strchr (s, '/0');
//返回值(查找的数组地址)赋初值,很重要。
found = NULL;
//从当前字符串超找字节c,并将返回指针赋给p,如果p不等于NULL,则执行循环。
//如果p等于NULL,说明已查找整个字符串,退出循环。
while ( (p = strchr (s, c)) != NULL )
{
//暂存查找到的数组地址。
found = p;

//截取已经查找过的字符串(将返回地址p的下一个字符地址作为字符串开头)。
s = p + 1;
}
//如果没有找到数组,则不会执行循环,found返回初值NULL。
//如果找到数组,返回p赋给found的指针地址。
return (char *) found;
}
//函数举例:
//void main()
//{
// char * pCh = "www.inkcool.com";
// char * pFind = strrchr(pCh, '.');
// if ( pFind != NULL)
// {
// printf("%s/n", pFind); //可以直接printf(pFind);printf("/n");左边的表达式是合二为一的表达方式;
// }
//}
//返回结果是:.com //注意strchr函数怎么用,有'.'而不是只返回com*/
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-120167-1.html
至少七个