
批號:
set list=4 8 1
for %%a in (%list%) do set highest=???
如何獲取最高值並將其保存到變數中?
答案1
以下批次程式碼將找到最大整數:
@echo off
setlocal enabledelayedexpansion
set list=4 8 1
set max=
for %%a in (%list%) do (
if not defined max (Set max=%%a)
if %%a GTR !max! (Set max=%%a)
)
echo max is %max%