题意:给定i,输出第i个回文数字。
分析:1,2,3,4,……,9------------------------------------------------------------------------------------------9个
11,12,13,14,……,19-------------------------------------------------------------------------------------9个
101,111,121,131,141,151,161,171,181,191,202,212,222,232,……,979,989,999-------------------------------90个
1001,1111,1221,1331,1441,……,9889,9999----------------------------------------------------------------90个
10001,10101,10201,10301,……,99899,99999--------------------------------------------------------------900个
规律是把回文串一分为二看,例如第四行,前两个数字是从10到99,共90个数字。而第三行也是从10到99,区别在于,需要去掉最后一位再反转,才是另一半(后两个数字)。
思路:先确定i所对应的回文数字的位数,再确定具体值。
1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include 13 #include