代码分享
可复制代码在这儿
int IsAutomorphic(int x)
{
int y;
y=x*x;
if(x==0 || x==1) return 1;
while(x!=0){
if(x%10!=y%10){
return 0;
}else{
x=x/10;
y=y/10;
}
}
return 1;
}
void FindAutomorphic(int lower, int upper)
{
int i,count=0;
for(i=lower;i<=upper;i++){
if(IsAutomorphic(i)==1){
printf("%d\n",i);
count++;
}
}if(count==0){
printf("None");
}
}
结果展示
本人的作品希望对大家有帮助哦~