如果是 + - * / 的- @echo off
- :start
- setlocal enabledelayedexpansion
- echo;&echo 请输入算式如:5*?=40
- set /p var=&cls
- set "var2=%var:?=%"
- set .-=a&set ./=a&set +=-&set -=+&set /=*&set "*=/"
- for /l %%a in (0 1 9) do set var2=!var2:%%a=!
- set "ff=%var2:~0,1%"&set "f=!%var2:~0,1%!"
- for /f "tokens=1-3 delims=+-/*=" %%a in ("%var%") do (
- if "%%c"=="?" (set ss=%%a%ff%%%b) else (
- if "%%a"=="?" (set ss=%%c%f%%%b) else (
- if defined .!ff! (set ss=%%a%ff%%%c) else set "ss=%%c%f%%%a"
- )))
- set /a num=!ss!
- set "str=!var:?=%num%!"
- echo 你输入的是:%var%
- echo 计算结果是:!str!
- endlocal&goto start
复制代码
|