#include
using namespace std;
const int Length1 = 3;
const int Length2 = 6;
bool match(int a);
bool check_onearray(char t[],int n);
int main()
{
for(int i = 100; i <= 999; ++i){
if(match(i))
{
cout< cout<<"\n";
}
}
return 0;
}
bool match(int a)//检查是否满足条件
{
char firsnum[4];//源数据
char sqarenum[7];//平方数
sprintf(firsnum,"%d",a);
sprintf(sqarenum,"%d",a*a);
if(check_onearray(firsnum,3) && check_onearray(sqarenum,6))
{
for(int i = 0; i < Length1; ++i)
for(int j = 0; j < Length2; ++j)
if(firsnum[i] == sqarenum[j])
{
return false;
break;
}
return true;
}
return false;
}
bool check_onearray(char t[],int n)//检查某个数是否有重复数字
{
for(int i = 0; i < n; ++i)
for(int j = i + 1; j {
if(t[i] == t[j])
return false;
}
return true;
}
--------------------next---------------------
阅读(1208) | 评论(0) | 转发(0) |