有大佬帮我看看为什么这样枚举输出不了数字吗
查看原帖
有大佬帮我看看为什么这样枚举输出不了数字吗
1101599
LeeZH楼主2023/10/5 00:26
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int arr[10000] = { 0 };
int p = 0;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	for (int i = 100; i <= 987; i++)
	{
		if (i % c == 0)
		{
			int k = i / c;
			int s1 = k * a;
			int s2 = k * b;
			int s3 = k * c;
			int l[9] = { 0 };
			int ans = 0;
			if (s1 > 100 && s1 < 1000 && s2 > 100 && s2 < 1000 && s3 > 100) {
				l[0] = s1 / 100; l[1] = s2 / 100; l[2] = s3 / 100; l[3] = s1 / 10 % 10; l[4] = s2 / 10 % 10; l[5] = s3 / 10 % 10; l[6] = s1 % 10; l[7] = s2 % 10; l[8] = s3 % 10;
				for (int i = 0; i < 9; i++)
					for (int j = 1; j < 9; j++)if (l[i] == l[j])ans += 1;
				if (ans == 0)
				{

					arr[p] = k * a;
					arr[p + 1] = k * b;
					arr[p + 2] = k * c;
					p += 3;

				}
			}
			int h = 0;
			while (arr[h] != 0)
			{
				cout << arr[h] << ' ' << arr[h + 1] << ' ' << arr[h + 2] << endl;
				h += 3;

			}

		}
		return 0;
	}
}
2023/10/5 00:26
加载中...