花了半天的成果
哈哈
利用的是学习C#时候的计算方法
o(∩_∩)o- @echo off&setlocal enabledelayedexpansion&color 02
- mode con cols=80 lines=12
- ::code by novaa @bbs.bathome.com 11/22/2007
- :kaishi
- echo.
- echo ╭─────────╮
- echo ╭────────┤选择要整理的文件夹├─────────╮
- echo │ ╰─────────╯ │
- echo │ novaa的十进制与二进制转换器 │
- echo │ bbs.bathome.com │
- echo │ │
- echo ╰────────────────────────────╯
-
- set /p xuanze=请选择转换的形式,10转2请输入1,2转10输入2,0退出:
- if %xuanze% equ 0 exit
- if %xuanze% equ 1 (goto :10to2) else (goto :2to10)
- :10to2
- set /p scanf=请输入你想转换的数字:
- set var=%scanf%
- set num=1
- echo 转换前数字为 %var%
- call :zhuanhuan
-
- :zhuanhuan
- set /a var%num%=%var%%%2
- set /a var=%var%/2
- set /a num+=1
- if !var! neq 0 goto :zhuanhuan else goto :echo
-
- :echo
- for /l %%a in (%num% -1 1) do set /p=!var%%a!<NUL
- pause>nul & cls & goto :kaishi
-
- :2to10
- set s1=1 & set s2=2 & set s3=4
- set /p scanf=请输入你想转换的数字:
- :jisuan
- set var=!scanf:~-3!
- set scanf=!scanf:~0,-3!
- set var1=!var:~0,1!
- if "%var:~1,1%"=="" (set var2=0) else (set var2=!var:~1,1!)
- if "%var:~2,1%"=="" (set var3=0) else (set var3=!var:~2,1!)
- set /a num=!num!+!var1!*!s3!+!var2!*!s2!+!var3!*!s1!
- if !scanf! equ 0 goto :echo2 else goto :lun
- :lun
- set /a s2*=8 & set /a s3*=8 & set /a s1*=8
- goto :jisuan
- :echo2
- echo !num!
- pause>nul & cls & goto :kaishi
复制代码
|