效率很低:
- @echo off
- :bgn
- Setlocal Enabledelayedexpansion
- set /p in=请输入:
- if not defined in goto :eof
- echo.
- set /a n=in-1,m=0
- :agn
- set /a m+=1,ans=0&set "ans_str="
- for /l %%a in (%m% 1 %n%) do (
- set /a ans+=%%a
- set "ans_str=!ans_str!%%a+"
- if !ans! gtr %in% (
- goto :agn
- ) else (
- if "!ans!"=="%in%" (
- set ans_str=!ans_str:~,-1!
- echo.!in!=!ans_str!&echo.
- goto :agn
- )
- )
- )
- endlocal
- goto :bgn
复制代码
|