#include <bits/stdc++.h>
using namespace std;
int main(){
int i=123;
for(int i=123;i<=789;i++){
int j=i*2;
int r=i*3;
int a[20]{},b=0;
for(int h=1;h<=i;h*=10){
a[++b]=i%(h*10)/h;
}
for(int h=1;h<=j;h*=10){
a[++b]=j%(h*10)/h;
}
for(int h=1;h<=r;h*=10){
a[++b]=r%(h*10)/h;
}
int d=0;
for(int h=1;h<=b;h++){
for(int g=h+1;g<=b;g++){
if(a[h]==a[g]){
d=1;
break;
}
}
}
if(d==0&&j<=999&&r<=999){
cout<<i<<" "<<j<<" "<<r<<"\n";
}
}
return 0;
}
编译后如下:
192 384 576
219 438 657
267 534 801
273 546 819
327 654 981
--------------------------------
Process exited after 0.3396 seconds with return value 0
请按任意键继续. . .