- @echo off
- set "STR1=A 1 B 2 C 3 D 4 E 5 F 6 G"
- set "STR2="
-
- call :_calc "%STR1%"
- echo STR2 = %STR2%
- pause
- goto :EOF
-
- :_calc
- (
- for /f "tokens=1,2,*" %%i in ("%~1") do (
- if "%%j" EQU "" echo 输入参数不成对 & goto :EOF
- IF "%STR2%" EQU "" (
- set "STR2=%STR2%%%i*%%j"
- ) else (
- set "STR2=%STR2%,%%i*%%j"
- )
- if "%%k" NEQ "" call :_calc "%%k"
- )
-
- goto :EOF
- )
复制代码
|