#include<stdio.h>
#include<string.h>
int main()
{
int count = 0;
char s[20], buf[99];
scanf("%s", s);
int abc,de,i;
for(abc=100;abc<=999;abc++)
for (de = 10; de <= 99; de++)
{
int x = abc * (de % 10);//得到“abc*e” ,即“-----”下方第一行的值
int y = abc * (de / 10);//得到“abc*d” ,即“-----”下方第二行的值
int z = abc * de;//得到最终的结果即abc*de
sprintf(buf, "%d%d%d%d%d", abc, de, x, y, z);//将abc,de,x,y,z的结果输出到字符数组buf中 例如abc=775 de=33 x=2325 y=2325 z=25575 buf=775332325232525575 在s数组中遍历查找buf[i]
int ok = 1;
for (i = 0; i < strlen(buf); i++)//遍历整个数组buf,看是否满足条件
if (strchr(s, buf[i]) == NULL)//在buf字符串中查找是否出现过s数组中的数 strchr--在s中查找buf[i]单个字符,若找到 返回在s中的位置 若无 返回null
ok = 0;
if (ok) //如果OK为真 --buf[i]全在s中
{
printf("<%d>\n", ++count);
printf("%5d\nX%4d\n-----\n%5d\n%4d\n-----\n%5d\n\n", abc, de, x, y, z);//按照5位数打印 ,不足5位前面打空格
}
}printf("The number of sulotions= %d\n", count);
//system("pause");
return 0;
}
蓝桥杯 竖式问题 题目理解
于 2022-02-21 19:16:56 首次发布