1、将四位数4 9 2 2的1 2 3 4位两两相加、减、乘,即1+2,1+3,1+4,2+3,2+4,3+4,1-2,1-3,1-4,2-3,2-4,3-4,1*2,1*3,1*4,2*3,2*4,3*4,得到数值3 6 6 1 1 4 5 2 2 7 7 0 6 8 8 8 8 4;- @echo off
- setlocal enabledelayedexpansion
- for /f "delims=" %%f in (dir /b ??.txt) do (
- for /f "tokens=1*" %%a in (%%f) do (
- set "a="
- for %%c in (%%b) do set /a a+=%%c
- echo !a!
- )
- )>%%~nf_1.txt
复制代码 2、在得到的数值中,统计0 1 2 3 4 5 6 7 8 9分别出现几次。(此例中,数值0出现1次,数值1出现2次,数值2出现2次,数值3出现3次,数值4出现2次,数值5出现1次,数值6出现3次,数值7出现2次,数值8出现4次,数值9出现0次)- @echo off
- setlocal enabledelayedexpansion
- for /f "delims=" %%f in (dir /b ??.txt) do (
- for /f "tokens=1*" %%a in (%%f) do (
- for %%c in (%%b) do set /a a[%%b]+=1
- )
- (for /l %%a in (0 1 9) do echo !a[%%a]!)>%%~nf_2.txt
- )
复制代码 3看不懂什么意思 |