满意答案
ljnbv
2013.10.12
采纳率:49% 等级:11
已帮助:18846人
源程序:
#include
int huiwen(long n)
{
long p;
p=n*n;
if(n<10)
if(p<10)
return 1;
else
if(p/10==p%10)
return 1;
else
return 0;
else if(n<100)
if(p<1000)
{if(n/10==n%10&&p/100==p%10)
return 1;
else
return 0;
}
else
{if(n/10==n%10&&p/1000==p%10&&p/100%10==p/10%10)
return 1;
else
return 0;
}
else
if(n/100==n%10&&p/10000==p%10&&p/1000%10==p/10%10)
return 1;
else
return 0;
}
main()
{
int i;
for(i=1;i<=300;i++)
if(huiwen(i))
printf("%d,%d\n",i,i*i);
}
运行结果:
1,1
2,4
3,9
11,121
22,484
101,10201
111,12321
121,14641
202,40804
212,44944
Press any key to continue
00分享举报