lucy2012 @ 2024-04-04 21:37:16
#include<bits/stdc++.h>
using namespace std;
int a,b,c,x,y,z,x1,y_1,z1,a1[10],sum=0;
int main(){
cin>>a>>b>>c;
for(int i=100;i<=1000/max(max(a,b),c);i++){
int num=1;
x=i*a;y=i*b;z=i*c;
x1=x;y_1=y;z1=z;
for(int j=1;j<=3;j++){
a1[j]=x1%10;
x1/=10;
}
for(int j=4;j<=6;j++){
a1[j]=y_1%10;
y_1/=10;
}
for(int j=7;j<=9;j++){
a1[j]=z1%10;
z1/=10;
}
sort(a1+1,a1+9);
for(int j=1;j<=9;j++){
if(j!=a1[j]){
num=0;
break;
}
}
if(num==1){
cout<<x<<' '<<y<<' '<<z<<endl;
sum=1;
}
}
if(sum==0) cout<<"No!!!";
return 0;
}
by Dream_Creator @ 2024-04-04 21:48:08
@lucy2012
#include<bits/stdc++.h>
using namespace std;
int a,b,c,x,y,z,x1,y_1,z1,a1[105],sum=0;
int main(){
cin>>a>>b>>c;
for(int i=0;i<=1000/max(max(a,b),c);i++){
int num=1;
x=i*a;y=i*b;z=i*c;
x1=x;y_1=y;z1=z;
for(int j=1;j<=3;j++){
a1[j]=x1%10;
x1/=10;
}
for(int j=4;j<=6;j++){
a1[j]=y_1%10;
y_1/=10;
}
for(int j=7;j<=9;j++){
a1[j]=z1%10;
z1/=10;
}
sort(a1+1,a1+10);
for(int j=1;j<=9;j++){
if(j!=a1[j]){
num=0;
break;
}
}
if(num==1){
cout<<x<<' '<<y<<' '<<z<<endl;
sum=1;
}
}
if(sum==0) cout<<"No!!!";
return 0;
}
by lucy2012 @ 2024-04-05 12:56:58
@Dream_Creator 谢谢!可为什么这样能过捏?
by Dream_Creator @ 2024-04-05 12:58:21
@lucy2012
sort(a+1,a+n+1) 表示将 a[1]~a[n] 排序,所以这里要用 sort(a1+1,a1+10);
by lucy2012 @ 2024-04-05 13:02:55
@Dream_Creator 懂了,谢谢!
by cdgh @ 2024-07-25 17:03:53
ψ(`∇´)ψ
by cdgh @ 2024-07-25 17:04:21
[]~( ̄▽ ̄)~*