tghr0503 @ 2024-02-29 14:52:57
#include<iostream>
using namespace std;
int num[12];
bool st[12],flag=0;
int a,b,c;
int a1=0,b1=0,c1=0;
void dfs(int x)
{
if(x>=9)
{
for(int i=1;i<=3;i++)
{
a1=a1*10+num[i];
}
for(int i=4;i<=6;i++)
{
b1=b1*10+num[i];
}
for(int i=7;i<=9;i++)
{
c1=c1*10+num[i];
}
if(a1*b==b1*a&&a1*c==c1*a)
{
cout<<a1<<" "<<b1<<" "<<c1<<endl;
flag=1;
}
return;
}
for(int i=1;i<=9;i++)
{
if(!st[i])
{
st[i]=1;
x++;
num[x]=i;
dfs(x);
x--;
st[i]=0;
}
}
}
int main()
{
cin>>a>>b>>c;
dfs(0);
if(!flag)cout<<"No!!!";
return 0;
}
by smart_stupid @ 2024-02-29 16:26:51
a1
,b1
,c1
三个变量在使用时没有初始化为
by tghr0503 @ 2024-02-29 18:12:42
@smart_stupid 感谢大佬,已AC
by xiaojie04 @ 2024-02-29 18:25:31
@tghr0503 哇,真的是你呀