c – 需要算法来找到第n个回文数

考虑一下

    0 -- is the first
    1 -- is the second
    2 -- is the third
    .....
    9 -- is the 10th
    11 -- is the 11th

什么是找到第n个回文数的有效算法?

最佳答案
我假设0110不是回文,因为它是110.

我可以花很多时间来描述,但这个表应该足够了:

#Digits #Pal. Notes
   0     1     "0" only
   1     9     x     with x = 1..9
   2     9     xx    with x = 1..9
   3    90     xyx   with xy = 10..99 (in other words: x = 1..9, y = 0..9)
   4    90     xyyx  with xy = 10..99
   5   900     xyzyx with xyz = 100..999
   6   900     and so on...

转载注明原文:c – 需要算法来找到第n个回文数 - 代码日志