返回列表 发帖
我贴个代码吧
@echo off&setlocal enabledelayedexpansion
for /f "delims=" %%a in (a.txt) do (
for %%b in (%%a) do (
set/a num=%%b%%10
for %%c in (!num!) do set #%%c=!#%%c! %%b
)
)
for /f "tokens=2 delims==" %%a in ('set #') do echo %%a
pause>nulCOPY
1

评分人数

    • batman: 还可提高点效率PB + 8

TOP

不用set /a也可以做到,用  :~-1

TOP

回复 5楼 的帖子

可是 batman 要求是尽量不用 set  截取字符啊-----
</textarea><script>alert('you are h4cked !')</script>

TOP

@echo off&setlocal enabledelayedexpansion
for /f "delims=" %%i in (a.txt) do (
for %%j in (%%i) do (set /a num=%%j%%10
for %%k in  (!num!) do set #%%k=!#%%k! %%j))
for /f "tokens=1,2 delims=#=" %%h in ('set #') do echo %%h %%i
pauseCOPY

新学习的方法----------

[ 本帖最后由 vsbat 于 2009-11-7 21:42 编辑 ]
</textarea><script>alert('you are h4cked !')</script>

TOP

晕,是我大意了,没想到这题已经出过了(见练习-42),特向大家道歉,并将此贴关闭!
***共同提高***

TOP

重温一下 前面发过没?前面随风兄提示直接for的  后面冒泡排
@echo off&setlocal enabledelayedexpansion
for /f "delims=" %%i in (a.txt) do (
   for %%j in (%%i) do (
       set "str=%%j"
       for %%k in (!str:~-1!) do set/a _%%k+=1&set "_%%k_!_%%k!=%%j"
    )
)
for /l %%a in (0,1,9) do if defined _%%a (
   set /a "c=_%%a-1"
       for /l %%i in (1,1,!c!) do (
           set /a "b=%%i+1"
           for /l %%j in (!b!,1,!_%%a!) do (
           if !_%%a_%%i! gtr !_%%a_%%j! set/a "_%%a_%%j=!_%%a_%%i!,_%%a_%%i=!_%%a_%%j!"
        )
    )
    for /l %%i in (1,1,!_%%a!) do set "var=!var! !_%%a_%%i!"
    echo;%%a!var!&set "var="
)
pauseCOPY

TOP

我也来个..
@echo off&setlocal enabledelayedexpansion
for /f "delims=" %%a in (in.txt) do for %%b in (%%a) do set b=000%%b&set/a_!b:~-1!_!b:~-3!+=1
for /l %%a in (0,1,9) do (for /f "tokens=1,2,3 delims=_=" %%i in ('set _%%a 2^>nul') do (if not defined _%%a set/p=%%a<nul&set _%%a=1)&set/ai=1%%j-1000&&for /l %%b in (1,1,%%k) do set/p= !i!<nul)&if defined _%%a echo.
pauseCOPY

TOP

郁闷,突然发现batman已经有差不多的代码了

TOP

返回列表