小改一下~ 帖子沉的真快 我下个星期再来喽~ 慢慢来~
简单的两个分数之间的加 减 乘 除 乘用 x 表示- @echo off &setlocal enabledelayedexpansion
- set /p input="输入格式如 1/2 + 3/4 两分数之间的乘法用 x 表示 : "
- call :readinput "%input%" inp
- call :readinput "%inp1:/= %" left
- call :readinput "%inp3:/= %" right
- if %inp2% equ + (set /a lr1=left1*right2 + right1*left2,lr2=left2*right2)
- if %inp2% equ - (set /a lr1=left1*right2 - right1*left2,lr2=left2*right2)
- if %inp2% equ x (set /a lr1=left1*right1,lr2=left2*right2)
- if %inp2% equ / (set /a lr1=left1*right2,lr2=left2*right1)
- call :cut %lr1% %lr2%
- set /a lr1=lr1/del,lr2=lr2/del
- echo,%lr1%/%lr2%
- pause>nul &exit
-
- :readinput
- set readinput=0
- for %%a in (%~1) do (set /a "readinput+=1" &set %2!readinput!=%%a)
- goto :eof
-
- ::Function::取出最大公约数,赋值给del
- :cut
- set /a a=%1,b=%2
- :cut-1
- set /a mod=a%%b,adb=a/b
- if %mod% equ 0 (set del=%b%) else (set /a "a=b,b=mod" &goto :cut-1)
- goto :eof
复制代码
|