本版
查看: 11121|回复: 0

[资源分享] 1~36进制转换器-批处理

[复制链接]
标签: 转换器  

Super Moderator

楼主(1#)
发表于 2013-5-29 20:53:14 | 只看该作者 |只看大图 |倒序浏览 |阅读模式
本文来自lyz810的空间,http://hi.baidu.com/lyz810/blog/item/db31cc42614f2b0273f05ddf.html

  1. @echo off &setlocal enabledelayedexpansion
    color 1e
    mode con cols=60 lines=10
    :start
    cls
    set b=
    set d=
    set e=
    set f=
    title 进制转换器
    set /p jzq=请输入转换前的进制数(1~36)
    set /p jzh=请输入转换后的进制数(1~36)
    set /p num=请输入数值
    set count=1
    set num=#%num%
    :check
    set b=!num:~-%count%,1!
    if /i "%b%"=="a" set b=10
    if /i "%b%"=="b" set b=11
    if /i "%b%"=="c" set b=12
    if /i "%b%"=="d" set b=13
    if /i "%b%"=="e" set b=14
    if /i "%b%"=="f" set b=15
    if /i "%b%"=="g" set b=16
    if /i "%b%"=="h" set b=17
    if /i "%b%"=="i" set b=18
    if /i "%b%"=="j" set b=19
    if /i "%b%"=="k" set b=20
    if /i "%b%"=="l" set b=21
    if /i "%b%"=="m" set b=22
    if /i "%b%"=="n" set b=23
    if /i "%b%"=="o" set b=24
    if /i "%b%"=="p" set b=25
    if /i "%b%"=="q" set b=26
    if /i "%b%"=="r" set b=27
    if /i "%b%"=="s" set b=28
    if /i "%b%"=="t" set b=29
    if /i "%b%"=="u" set b=30
    if /i "%b%"=="v" set b=31
    if /i "%b%"=="w" set b=32
    if /i "%b%"=="x" set b=33
    if /i "%b%"=="y" set b=34
    if /i "%b%"=="z" set b=35
    if "%b%"=="#" goto run
    if %b% GEQ %jzq% echo 输入有误,请重新输入 &pause >nul &goto start
    set /a count+=1
    goto check
    :run
    title 正在将%jzq%进制数%num%转换为%jzh%进制数,请稍后......
    echo 正在将%jzq%进制数%num%转换为%jzh%进制数,请稍后......
    if %jzq% EQU 1 goto run_5
    set count=1
    set a=1
    set c=0
    :run_1
    set b=!num:~-%count%,1!
    if /i "%b%"=="a" set b=10
    if /i "%b%"=="b" set b=11
    if /i "%b%"=="c" set b=12
    if /i "%b%"=="d" set b=13
    if /i "%b%"=="e" set b=14
    if /i "%b%"=="f" set b=15
    if /i "%b%"=="g" set b=16
    if /i "%b%"=="h" set b=17
    if /i "%b%"=="i" set b=18
    if /i "%b%"=="j" set b=19
    if /i "%b%"=="k" set b=20
    if /i "%b%"=="l" set b=21
    if /i "%b%"=="m" set b=22
    if /i "%b%"=="n" set b=23
    if /i "%b%"=="o" set b=24
    if /i "%b%"=="p" set b=25
    if /i "%b%"=="q" set b=26
    if /i "%b%"=="r" set b=27
    if /i "%b%"=="s" set b=28
    if /i "%b%"=="t" set b=29
    if /i "%b%"=="u" set b=30
    if /i "%b%"=="v" set b=31
    if /i "%b%"=="w" set b=32
    if /i "%b%"=="x" set b=33
    if /i "%b%"=="y" set b=34
    if /i "%b%"=="z" set b=35
    if "%b%"=="#" goto run_2
    set /a c=%b%*%a%+%c%
    set /a a*=%jzq%
    set /a count+=1
    goto run_1
    :run_2
    if %jzh% EQU 1 goto run_3
    set /a d=%c%-%c%/%jzh%*%jzh%
    set /a c=%c%/%jzh%
    set f=%d%
    if %d% EQU 10 set f=A
    if %d% EQU 11 set f=B
    if %d% EQU 12 set f=C
    if %d% EQU 13 set f=D
    if %d% EQU 14 set f=E
    if %d% EQU 15 set f=F
    if %d% EQU 16 set f=G
    if %d% EQU 17 set f=H
    if %d% EQU 18 set f=I
    if %d% EQU 19 set f=J
    if %d% EQU 20 set f=K
    if %d% EQU 21 set f=L
    if %d% EQU 22 set f=M
    if %d% EQU 23 set f=N
    if %d% EQU 24 set f=O
    if %d% EQU 25 set f=P
    if %d% EQU 26 set f=Q
    if %d% EQU 27 set f=R
    if %d% EQU 28 set f=S
    if %d% EQU 29 set f=T
    if %d% EQU 30 set f=U
    if %d% EQU 31 set f=V
    if %d% EQU 32 set f=W
    if %d% EQU 33 set f=X
    if %d% EQU 34 set f=Y
    if %d% EQU 35 set f=Z
    set e=%f%%e%
    if %c% EQU 0 goto stop
    goto run_2
    :run_3
    set count=0
    set g=0
    :run_4
    set g=%g%0
    set /a count+=1
    if %count% EQU %c% set e=%g% &goto stop
    goto run_4
    :run_5
    set count=1
    :run_6
    set b=!num:~-%count%,1!
    set /a c=%count%-2
    if "%b%"=="#" goto run_2
    set /a count+=1
    goto run_6
    :stop
    cls
    title %jzq%进制数%num:~1%转换为%jzh%进制的结果为%e%
    echo %jzq%进制数%num:~1%转换为%jzh%进制的结果为%e%
    pause >nul
    goto start


回复

支持 | 反对  0 支持 / 0 反对 评分 举报

联系我们(Contact)|手机版|萝卜头IT论坛 ( 苏ICP备15050961号-1 )

GMT+8, 2026-11-04 09:04 , Processed in 0.07 second(s), 20 queries , Gzip On.

快速回复 返回顶部 返回列表