再来,还是非位运算版的:- @echo off&setlocal enabledelayedexpansion
- set /a n=1
- :lp
- set /a n*=2,we+=1
- if %n% neq 0 goto lp
- set /p var=请输入整数:
- if %var% lss 0 set "-=1"&set "var=%var:~1%"
- for /l %%a in (1,1,%we%) do (
- if !var! geq 1 (
- set /a yu=var%%2,var/=2
- if defined - set /a yu=1-yu
- set "num=!num!!yu!"
- ) else (
- set "num=!num!0%-%"
- )
- )
- if defined - call :loop
- echo %str%%num%
- pause>nul&goto :eof
- :loop
- set "a=%num:~,1%"
- set /a a+=1&if !a! equ 2 set /a a=0
- set "str=!a!%str%"&set "num=%num:~1%"
- if %a% equ 0 goto loop
复制代码
|