回复 21# haichuan5121
根据24楼代码进行完善,满足21楼2个附加条件:
1.非法输入提示重新输入;
2.只有一组C0-E0不执行操作;- @echo off
- setlocal enabledelayedexpansion
- :a
- set /p n=Please Input a number:
- set x1=C0_E0,1,0,0
- set x2=C0_E0,2,0,0
- set x3=C0_E0,3,0,1
- set a=1
- for /l %%i in (1,1,3) do (
- for /l %%j in (1,1,3) do (
- set m=%%i%%j
- if !n! equ !m! (
- set a=
- set a1=!x%%i!
- set a2=!x%%j!
- )
- )
- )
- if defined a (
- echo,Input error!
- goto :a
- )
- set Groups="C0_E0,1,0,0" "C0_E0,2,0,0" "C0_E0,3,0,1"
- set Sub=`
- for /f "delims=" %%i in ('findstr /imr "C0_E0,.*C0_E0," *.RCP^|findstr /iv "04T"') do (
- (for /f "delims=" %%j in ('type "%%i"') do (
- set "str=%%j"
- for %%k in (%Groups%) do set "str=!str:%%~k=%Sub%!"
- for /f "tokens=1,2* delims=%Sub%" %%a in ("!str!") do (
- if not "%%c"=="" (
- echo,%%a!a1!%%b!a2!%%c
- ) else (
- echo,%%j
- )
- )
- ))>"New-%%i"
- )
- pause
复制代码
|