参照9楼的代码,按从小到大的顺序完全列出10000以内的回文数
(效率应该不会差到哪里去的。)- @echo off
- set /a total=9
- for /l %%i in (1,1,9) do echo %%i%%i
- for /l %%i in (1,1,9) do (
- for /l %%j in (0,1,9) do (
- echo %%i%%j%%i
- set /a total+=1
- )
- )
- for /l %%i in (1,1,9) do (
- for /l %%j in (0,1,9) do (
- echo %%i%%j%%j%%i
- set /a total+=1
- )
- )
- echo 一万以内共有%total%个回文数!
- pause>nul
复制代码
|