1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
#include "stdio.h" int isreserves(int sum); int main(){ for (int i = 0; i < 256; ++i) { int sum=i*i; int reserves=isreserves(sum); if(i*i==reserves) printf("%d的平方为%d,他的逆序数是%d\n",i,i*i,reserves); } } int isreserves(int sum){ int reserves=0; while(sum!=0){ int remain=sum%10; reserves=reserves*10+remain; sum=sum/10; } return reserves; }
|