#include<stdio.h>
#include<math.h>
int main()
{
int a ,b , n , m ;
for(a = 1;a<=9;a++)
for(b = 0;b<=9;b++)
{
n = a*1100+b*11;
m = floor(sqrt(n)+0.5);
if(m*m==n)printf("%d\n",n);
}
return 0;
}
判断m是不是n开方后得到的整数,floor(x+0.5) 表示区间长度为一 从0.5到1.5
floor函数表示返回不超过x的最大整数
枚举平方根
#include<stdio.h>
int main()
{
int x ,n , hi , lo ;
for(x = 1;;x++)
{
n = x*x;
if(n<1000)
continue;//continue表示不执行下面的操作
if(n>9999)
break;
hi = n/100;
lo = n%100;
if(hi/10==hi%10&&lo/10==lo%10)判断是否为aabb
printf("%d\n",n);
}
return 0;
}