王宏宇11 @ 2019-04-28 00:14:12
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdlib>
using namespace std;
int q[10];
int w[10];
int e[10];
bool check(int s,int d,int f)
{int i=1;
while(s!=0)
{q[i]=s%10;
s=s/10;
w[i]=d%10;
d=d/10;
e[i]=f%10;
f=f/10;
i++;//取位数
}
for(int i=1;i<=3;i++)
for(int j=1;j<=3;j++)
for(int k=1;k<=3;k++)
{if(q[i]==w[j]||q[i]==e[k]||w[j]==e[k])
return 0;
if(q[i]==0||w[j]==0||e[k]==0)
return 0;
//if(q[i]==q[i+1]||q[i]==q[i+2]||q[i+1]==q[i+2])
}
if(q[i]==q[i+1]||q[i]==q[i+2]||q[i+1]==q[i+2]) return 0;
if(w[i]==w[i+1]||w[i]==w[i+2]||w[i+1]==w[i+2]) return 0;
if(e[i]==e[i+1]||e[i]==e[i+2]||e[i+1]==e[i+2]) return 0;
//判断每个位数有没有重
return 1;
}
int main()
{int a,b,c;
bool flag=0;
cin>>a>>b>>c;
for(int i=123;i<=987;i++)
{int x=a*i,y=b*i,z=c*i;
if(x<=999&&y<=999&z<=999&&check(x,y,z)==1)
{cout<<x<<" "<<y<<" "<<z<<endl;
flag=1;
}
}
if(flag==0)
cout<<"No!!!";
return 0;
}
if(q[i]==q[i+1]||q[i]==q[i+2]||q[i+1]==q[i+2]) return 0;
if(w[i]==w[i+1]||w[i]==w[i+2]||w[i+1]==w[i+2]) return 0;
if(e[i]==e[i+1]||e[i]==e[i+2]||e[i+1]==e[i+2]) return 0;
//判断每个位数有没有重
就是这个地方,哪里错了,萌新不懂QWQ
by Smile_Cindy @ 2019-04-28 08:44:28
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdlib>
using namespace std;
int q[10];
int w[10];
int e[10];
bool check(int s,int d,int f)
{int i=1;
while(s!=0)
{q[i]=s%10;
s=s/10;
w[i]=d%10;
d=d/10;
e[i]=f%10;
f=f/10;
i++;//取位数
}
for(int i=1;i<=3;i++)
for(int j=1;j<=3;j++)
for(int k=1;k<=3;k++)
{if(q[i]==w[j]||q[i]==e[k]||w[j]==e[k])
return 0;
if(q[i]==0||w[j]==0||e[k]==0)
return 0;
//if(q[i]==q[i+1]||q[i]==q[i+2]||q[i+1]==q[i+2])
}
if(q[i]==q[i+1]||q[i]==q[i+2]||q[i+1]==q[i+2]) return 0;
if(w[i]==w[i+1]||w[i]==w[i+2]||w[i+1]==w[i+2]) return 0;
if(e[i]==e[i+1]||e[i]==e[i+2]||e[i+1]==e[i+2]) return 0;
//判断每个位数有没有重
return 1;
}
int main()
{int a,b,c;
bool flag=0;
cin>>a>>b>>c;
for(int i=123;i<=987;i++)
{int x=a*i,y=b*i,z=c*i;
if(x<=999&&y<=999&z<=999&&check(x,y,z)==1)
{cout<<x<<" "<<y<<" "<<z<<endl;
flag=1;
}
}
if(flag==0)
cout<<"No!!!";
return 0;
}
by 王宏宇11 @ 2019-04-29 00:09:20
@Alpha 大佬,您是什么意思,萌新不懂QWQ