复制代码
- @echo off
- title 四则运算
- color b0
- mode con cols=40 lines=30
- :begin
- cls
- echo
- echo ___________________________
- echo a.加法
- echo ___________________________
- echo b.减法
- echo ___________________________
- echo c.乘法
- echo ___________________________
- echo d.除法
- echo ___________________________
- echo e.乘方
- echo ___________________________
- echo f.开方
- echo ___________________________
- echo g.鸡兔同笼
- echo ___________________________
- echo t.退出
- echo ___________________________
- set /p a=
- cls
- if %a% equ a (
- goto a
- )
- if %a% equ b (
- goto b
- )
- if %a% equ c (
- goto c
- )
- if %a% equ d (
- goto d
- )
- if %a% equ e (
- goto e
- )
- if %a% equ f (
- goto f
- )
- if %a% equ t (
- goto t
- )
- if %a% equ g (
- goto g
- )
- :a
- set /p s=请输入加数
- set /p d=请输入另一个加数
- set /a n=%s%+%d%
- cls
- echo 结果是%n%
- pause>nul
- goto begin
- :b
- set /p sa=请输入被减数
- set /p da=请输入减数
- set /a na=%sa%-%da%
- cls
- echo 结果是%na%
- pause>nul
- goto begin
- :c
- set /p ss=请输入乘数
- set /p ds=请输入另一个乘数
- set /a ns=%ss%*%ds%
- cls
- echo 结果是%ns%
- pause>nul
- goto begin
- :d
- set /p sf=请输入被除数
- set /p df=请输入除数
- set /a nf=%sf%/%df%
- cls
- echo 结果是%nf%
- pause>nul
- goto begin
- :e
- set /p sfa=请输入被平方数
- set /a nfd=%sfa%*%sfa%
- cls
- echo 结果是%nfd%
- pause>nul
- goto begin
- :f
- cls
- set /p n=输入待开方数:
- set a=2
- set r=
- :int_part
- set /a old_a=a,a=(n/a+a)/2
- if %old_a% lss %a% goto int_part
- set /a delta=old_a-a
- if %delta% gtr 1 goto int_part
- ::prepare
- set /a near_n=a*a
- if %near_n% equ %n% goto end
- set /a t=n-near_n,u=a
- :dec_part
- set /a t*=100,d=10,tol_d=MAX/(u*20)
- if %tol_d% lss 9 goto end
- if %t% lss 0 goto end
- :try_d
- set /a d-=1,v=d*(d+u*20)
- if %v% gtr %t% goto try_d
- set /a t-=v,u=u*10+d
- set r=%r%%d%
- goto dec_part
- :end
- if "%r%" neq "" set a=%a%.%r%
- echo 结果:%a%
- pause>nul
- goto begin
- :t
- exit
- :g
- set /p a=请输入头数
- set /p b=请输入脚数
- set /a n=(4*%a%-%b%)/2
- set /a m=%a%-%n%
- echo 兔%m%只,鸡%n%只
- pause>nul
- goto begin
欢迎光临 批处理之家 (http://www.bathome.net/) | Powered by Discuz! 7.2 |