求调
查看原帖
求调
1586238
easy235楼主2024/11/21 20:28

#include <stdio.h>

int p(int n1[1000], int n2[1000], int n3[1000])

{

	int i;
  
	for (i = 1;i < 10;i++)
  
	{
		if (n1[i] + n2[i] + n3[i] > 1)
			break;
	}
	if (i == 10)
		return 1;
	else
		return 0;
}

int main()
{


int i, n1[1000] = { 0 }, n2[1000] = { 0 }, n3[1000] = { 0 }, a, b, x;
  
	for (i = 123;i < 988;i++)
	{
		a = i * 2;
		b = i * 3;
		while (i > 0)
		{
			x = i % 10;
			i = i / 10;
			n1[x]++;
		}
		while (a > 0)
		{
			x = a % 10;
			a = a / 10;
			n2[x]++;
		}
		while (b > 0)
		{
			x = b % 10;
			b = b / 10;
			n3[x]++;
		}
		if (p(n1, n2, n3))
			printf("%d,%d,%d", i, a, b);
	}
	return 0;
}
2024/11/21 20:28
加载中...