wxcute (冰疼)当前离线
荣誉版主
shelluserwlb 当前离线
一级士官
@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复制代码
TOP
@echo off 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 ) ) pause复制代码
@echo off goto :START 我国古代有一种回文诗,倒念顺念都有意思,例如“人过大佛寺”,倒读起来便是“寺佛大过人”。还 有经典的对联“客上天然居,居然天上客”。此种例子举不胜举。 从左向右读与从右向左读完全一样的数字就是回文数,如11、121、767等等。 :START MODE CON LINES=200 setlocal enabledelayedexpansion set /a total=0 for /l %%i in (11,1,10000) do ( set num=%%i :: 判断小于1000的数字 if !num! lss 1000 ( if "!num:~0,1!"=="!num:~-1,1!" ( echo !num! & set /a total+=1 ) ) ::判断大于等于1000且小于10000的数字 if !num! geq 1000 ( if !num! lss 10000 ( if "!num:~0,1!"=="!num:~-1,1!" ( if "!num:~1,1!"=="!num:~2,1!" ( echo !num! & set /a total+=1 )) )) ) echo 一万以内总共有%total%个回文件数。 endlocal & pause>NUL复制代码
zqy220422 当前离线
列兵
悬崖之树 当前离线
上尉
@echo off setlocal enabledelayedexpansion if exist 1.txt del 1.txt :ks set /p num=请输入一个最多5位的正整数: if %num% gtr 999999 echo 你的数太大了,请重新输入!& goto ks for /l %%i in (0,1,%num%) do ( set a=%%i if "!a:~0,1!"=="!a:~-1!" ( if "!a:~3,1!"=="" ( echo !a!>>1.txt ) else ( if "!a:~1,1!"=="!a:~-2,1!" ( if "!a:~5,1!"=="" ( echo !a!>>1.txt ) ) ) ) ) echo 结果已经保存在当前目录下的1.txt文件中 pause复制代码
@echo off setlocal enabledelayedexpansion for /l %%i in (0,1,1200) do ( set a=%%i if "!a:~0,1!"=="!a:~-1!" ( if "!a:~1,1!"=="" ( echo !a!>>1.txt ) else ( if "!a:~1,1!"=="!a:~-2,1!" ( if "!a:~3,1!"=="" ( echo !a!>>1.txt ) else echo 你的数太大啦!&goto out ) ) ) ) :out pause复制代码
mxxcgzxxx (黑雨)当前离线
中尉
@echo off setlocal enabledelayedexpansion for /l %%i in (1 1 99) do ( set /a a=%%i/10+%%i%%10*10+100 if !a:~-1!==0 (set a=!a:~-2,1!) else (set a=!a:~-2!) echo %%i!a! for /l %%j in (0 1 9) do echo %%i%%j!a! pause>nul ) set /a b=99*11 echo 100000以内有%b%个回文数 pause>nul复制代码
PCL505512957 当前离线
@if not defined debug @echo off&setlocal enabledelayedexpansion for /l %%i in (1 1 1000) do ( set /a a=%%i/100 set /a b=%%i/10-!a!*10 set /a c=%%i-!a!*100-!b!*10 if !c! equ !a! (if not !a! equ 0 echo %%i) ) pause >nul复制代码
scarcr 当前离线
@echo off setlocal enabledelayedexpansion for /l %%i in (10 1 999) do ( set "a=%%i" if "!a:~,1!" equ "!a:~-1!" (echo !a!) ) pause复制代码
评分人数
lxzzr (庄生晓梦)当前离线
论坛巡查
@echo off&setlocal enabledelayedexpansion for /l %%a in (100,1,10000000) do ( set a=%%a if "!a:~0,1!" == "!a:~-1,1!" ( if "!a:~1,1!" == "!a:~-2,1!" ( if "!a:~2,1!" == "!a:~-3,1!" ( echo !a! )))) pause复制代码
sjzong 当前离线
六级士官
@echo off setlocal enabledelayedexpansion for %%a in (1 2 3 4 5 6 7 8 9) do ( rem 以下两句是求两位的回文数 echo %%a%%a set/a num+=1 for %%b in (0 1 2 3 4 5 6 7 8 9) do ( rem 以下两句是求三位的回文数 echo %%a%%b%%a set/a num+=1 rem 以下两句是求四位的回文数 echo %%a%%b%%b%%a set/a num+=1 ) ) echo 10000以内回文数共有!num! pause复制代码
cainiao736 当前离线
二级士官
@echo off&setlocal enabledelayedexpansion for /l %%i in ( 10,1,999 ) do ( set str=%%i set a=!str:~0,1! set b=!str:~-1,1! if "!a!"=="!b!" echo %%i) pause复制代码
@echo off&setlocal enabledelayedexpansion for /l %%i in (10,1,10000) do ( set str=%%i set a=!str:~0,1! set b=!str:~-1,1! set c=!str:~1,1! set d=!str:~-2,1! if "!a!"=="!b!" ( if "!c!"=="!d!" echo !str!)) pause复制代码
keen 当前离线
@echo off&setlocal enabledelayedexpansion for /l %%i in (0 1 10000) do ( set a=%%i if "!a:~0,1!"=="!a:~-1,1!" if !a! lss 1000 (echo !a!) else (if "!a:~1,1!"=="!a:~-2,1!" echo !a!) ) pause复制代码
@echo off&setlocal enabledelayedexpansion for /l %%i in (0 1 1000) do ( set a=%%i if "!a:~0,1!"=="!a:~-1,1!" echo !a! ) for /l %%i in (1001 1 10000) do ( set a=%%i if "!a:~0,1!"=="!a:~-1,1!" if "!a:~1,1!"=="!a:~-2,1!" echo !a! ) pause复制代码