@echo offrem 写一行比较简洁,缺点是每一种判断内不方便写多条语句set varA=Bif "%varA%"=="A" (echo %varA% is A) else if "%varA%"=="B" (echo %varA% is B) else (echo %varA% is C)pause
@echo offrem 在这种写法可读性好,也能执行多语句,但兼容性不太好set varA=Bif "%varA%"=="A" ( echo %varA% is A echo AAA) else if "%varA%"=="B" ( echo %varA% is B echo BBB) else ( echo %varA% is C echo CCC)pause
@echo offrem 可读性好,兼容性好setlocal EnableDelayedExpansionset option=2set sum=-1if %option% == 3 ( echo three set /a sum=%option%*%option%*%option%) ^else if %option% == 2 ( echo two set /a sum=2*%option%) ^else if %option% == 1 ( echo one set /a sum=%option% ) ^else ( echo zero set /a sum=0 )echo sum = !sum!pause
推荐本站淘宝优惠价购买喜欢的宝贝:
本文链接:https://hqyman.cn/post/2661.html 非本站原创文章欢迎转载,原创文章需保留本站地址!
休息一下~~