本帖最后由 shelluserwlb 于 2014-11-10 07:41 编辑
- @echo off
- color 9e
- setlocal EnableDelayedExpansion
- set /a num=0
- for /f "tokens=1-6" %%i in (千字文.txt) do (
- set /a num+=1 & set str!num!=%%i
- set /a num+=1 & set str!num!=%%j
- set /a num+=1 & set str!num!=%%k
- set /a num+=1 & set str!num!=%%l
- set /a num+=1 & set str!num!=%%m
- set /a num+=1 & set str!num!=%%n
- )
- set /a a=%num%-6
- for /l %%i in (%a%,1,%num%) do if defined str%%i set /a a=%%i
- set /a total= a * 4
- echo 《千字文》共有汉字字数:%total%个
- set str=
- for /l %%i in (%a%,-1,1) do (
- set str=!str!!str%%i:~0,1!
- set str=!str!!str%%i:~1,1!
- set str=!str!!str%%i:~2,1!
- set str=!str!!str%%i:~3,1!
- echo !str%%i!
- )
- echo.
- set dup=
- for /l %%i in (0,1,%total%) do (
- set ch=!str:~%%i,1!
- if defined str[!ch!] set dup=!dup! !ch!
- set str[!ch!]=!ch!
- )
- echo 简体字版《千字文》中重复的字有:!dup!
- endlocal
- echo.& pause
复制代码
|