zhishisen @ 2024-10-19 10:51:32
#include <iostream>
#include <algorithm>
using namespace std;
int arr[10] = {0,1,2,3,4,5,6,7,8,9};
int main()
{
int a, b, c;
cin >> a >> b >> c;
int cnt;
do {
int x = arr[1] * 100 + arr[2] * 10 + arr[3];
int y = arr[4] * 100 + arr[5] * 10 + arr[6];
int z = arr[7] * 100 + arr[8] * 10 + arr[9];
if ((x * b == y && x * c == z) || (x == a && y == b && z == c))
{
printf("%d %d %d\n", x, y, z);
cnt ++;
}
} while(next_permutation(a+1, a+10));
if (cnt == 0)
{
cout << "No!!!";
}
return 0;
}
by fhzm_kkk @ 2024-10-19 16:03:18
@zhishisen
#include <iostream>
#include <algorithm>
using namespace std;
int arr[10] = {0,1,2,3,4,5,6,7,8,9};
int main()
{
int a, b, c;
cin >> a >> b >> c;
int cnt;
do {
int x = arr[1] * 100 + arr[2] * 10 + arr[3];
int y = arr[4] * 100 + arr[5] * 10 + arr[6];
int z = arr[7] * 100 + arr[8] * 10 + arr[9];
if ((x * b == y && x * c == z) || (x == a && y == b && z == c))
{
printf("%d %d %d\n", x, y, z);
cnt ++;
}
} while(next_permutation(a+1, a+10,1));//这里
if (cnt == 0)
{
cout << "No!!!";
}
return 0;
}
by zhishisen @ 2024-10-20 16:44:08
@fhzm_kkk 感谢
by fhzm_kkk @ 2024-10-21 20:52:38
@zhishisen # 第三个参数是第一个下标的开始元素 此贴终