首先编写判断一个五位数和一个四位数9个数字是否相同 利用标记数组的方法判断 若是不相同返回1,相同返回0

int panbie(int x, int y)
{
	int i, m, n;
	int a[10] = { 0 };//定义标记数组
	for (i = 0; i <= 4; i++)
	{
		n= x % 10;
		a[n]++;//数组标记
		x = x/ 10;//
	}
	for (i = 0; i <= 3; i++)
	{
		n = y % 10;
		a[n]++;//数组标记
		y = y/ 10;
	}

	for (i = 0; i <= 9;i++)
	if (a[i] >= 2)
		return 0;
	return 1;
}

主函数利用循环遍历所有五位数和四位数

for (wu = 10000; wu < 100000;wu++)
	for (si = 1000; si < 10000; si++)

遍历时找出符合题目条件的五位数和四位数

if (wu == (2 * si))
		{
			i = panbie(wu, si);//调用判断函数
			if (i == 1)
				printf("%d=2*%d\n", wu, si);
		}

满足条件后输出即可 完整源代码如下

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int panbie(int x, int y)
{
	int i, m, n;
	int a[10] = { 0 };
	for (i = 0; i <= 4; i++)
	{
		n= x % 10;
		a[n]++;
		x = x/ 10;//
	}
	for (i = 0; i <= 3; i++)
	{
		n = y % 10;
		a[n]++;
		y = y/ 10;
	}

	for (i = 0; i <= 9;i++)
	if (a[i] >= 2)
		return 0;
	return 1;

}

int main()
{
	int wu, si,i;
	for (wu = 10000; wu < 100000;wu++)
	for (si = 1000; si < 10000; si++)
	{
		if (wu == (2 * si))
		{
			i = panbie(wu, si);
			//printf("%d\n", i);
			if (i == 1)
				printf("%d=2*%d\n", wu, si);
		}

	}
	system("pause");
	return 0;
}

运行结果

10476=2*5238
10478=2*5239
10728=2*5364
10764=2*5382
10784=2*5392
10872=2*5436
10972=2*5486
12708=2*6354
12870=2*6435
12970=2*6485
13458=2*6729
13584=2*6792
13704=2*6852
13854=2*6927
14538=2*7269
14586=2*7293
14658=2*7329
15384=2*7692
15846=2*7923
15864=2*7932
16470=2*8235
16704=2*8352
17046=2*8523
17064=2*8532
17092=2*8546
17290=2*8645
17304=2*8652
18470=2*9235
18534=2*9267
18546=2*9273
18654=2*9327
18704=2*9352
请按任意键继续. . .