解题思路:
注意事项: n次幂函数Pow().
参考代码:
#include <stdio.h>
#include <math.h>
int main()
{
int a,b,n,m,t;
for(n=1000; n<10000; n++)//遍历所有的四位数
{
a = n / 100; //分离千位、百位
b = n % 100; //分离十位、个位
t = a+b;
m = pow(t,2);
if(m == n)
{
printf("%d\n",m);
}
}
return 0;
}
0.0分
0 人评分