蓝桥杯 竖式问题 题目理解

在这里插入图片描述

#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;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值