- @echo off
- :: code by ieutk @ bbs.bathome.net
- title 测试你的身体质量指数(BMI)
- mode con: cols=60 lines=14
- :: ***********************************************************
- :main_w
- cls&echo.
- set weight=[]
- set /p weight= 请输入体重(单位:kg):
- call :ie weight %weight% main_w
- :: 体重数据输入
- :: ***********************************************************
- :main_h
- cls&echo.
- set height=[]
- set /p height= 请输入身高(单位:cm):
- call :ie height %height% main_h
- :: 身高数据输入
- :: ***********************************************************
- set /a bmi=^(%weight%*10000^)/^(%height%*%height%^)
- :: 身体质量指数的运算公式是: 体重/(身高*身高)。注意此处的身高单位是M,而不是CM
- call :out %bmi%
-
- :out
- set "yo=if %1 equ %%a msg /v /w %username%"
- if %1 gtr 30 msg /v /w %username% " 不要再闹了!!!哪有这种身材~~ ">nul&goto main_w
- for /l %%a in (28 1 30) do %yo% " 你再不减肥就完蛋了! ">nul&goto main_w
- for /l %%a in (24 1 27) do %yo% " 你是不是胖了点? ">nul&goto main_w
- for /l %%a in (21 1 23) do %yo% " 我敢打赌,你一定经常抢吃,不然不会偏胖! ">nul&goto main_w
- for /l %%a in (19 1 20) do %yo% " 哇~!!棒极了,是标准身材! ">nul&goto main_w
- for /l %%a in (17 1 18) do %yo% " 朋友,明显你营养不良(^_^)! ">nul&goto main_w
- if %1 lss 17 msg /v /w %username% " 按照生物学来说这种生物是不能生存的~! ">nul&goto main_w
-
- :ie
- if "%1"=="[]" goto %3
- echo %2|findstr "^[1-9][0-9]*$">nul||goto %3
- if %2 geq 250 msg /v /w %username% " 你输入的数字让我头都大了,按确定重新输入!">nul&goto %3
- goto :eof
复制代码