我是这样写的 没测试特殊情况- @echo off&setlocal enabledelayedexpansion
- set n=2147483647
- for /f "delims=" %%a in (a.txt) do (
- for %%i in (%%a) do (
- if "%%i"=="end" set flog=&echo !n!&set n=2147483647
- if defined flog (
- set "str=%%i"
- if "!str:~,1!"=="a" (
- set "m=!str:~1!"
- set str=!str:.=!
- for /l %%j in (0 1 9) do set str=!str:%%j=!
- if "!str!"=="a" (
- set n1=&set "n2="
- if "!n:~,1!" neq "-" (
- for %%b in (n m) do for /f "tokens=1* delims=." %%m in ("!%%b!") do set %%b1=%%m&set "%%b2=%%n"
- if !n1! equ !m1! (
- if not "!n2!"=="" if "!n2!" gtr "!m2!" set n=!m!
- ) else if !n1! gtr !m1! set n=!m!
- )
- )
- if "!str!"=="a-" (
- if "!n:~,1!" equ "-" (
- for %%b in (n m) do for /f "tokens=1* delims=." %%m in ("!%%b!") do set %%b1=%%m&set "%%b2=%%n"
- if !n1! equ !m1! (
- if not "!m2!"=="" if "!n2!" lss "!m2!" set n=!m!
- ) else if !n1! gtr !m1! set n=!m!
- ) else set n=!m!
- )))
- if "%%i"=="home" set "flog=x"
- ))
- pause
复制代码
|