[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
我贴个代码吧
  1. @echo off&setlocal enabledelayedexpansion
  2. for /f "delims=" %%a in (a.txt) do (
  3. for %%b in (%%a) do (
  4. set/a num=%%b%%10
  5. for %%c in (!num!) do set #%%c=!#%%c! %%b
  6. )
  7. )
  8. for /f "tokens=2 delims==" %%a in ('set #') do echo %%a
  9. pause>nul
复制代码
1

评分人数

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

TOP

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

TOP

回复 5楼 的帖子

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

TOP

  1. @echo off&setlocal enabledelayedexpansion
  2. for /f "delims=" %%i in (a.txt) do (
  3. for %%j in (%%i) do (set /a num=%%j%%10
  4. for %%k in  (!num!) do set #%%k=!#%%k! %%j))
  5. for /f "tokens=1,2 delims=#=" %%h in ('set #') do echo %%h %%i
  6. pause
复制代码

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

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

TOP

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

TOP

重温一下 前面发过没?前面随风兄提示直接for的  后面冒泡排
  1. @echo off&setlocal enabledelayedexpansion
  2. for /f "delims=" %%i in (a.txt) do (
  3.    for %%j in (%%i) do (
  4.        set "str=%%j"
  5.        for %%k in (!str:~-1!) do set/a _%%k+=1&set "_%%k_!_%%k!=%%j"
  6.     )
  7. )
  8. for /l %%a in (0,1,9) do if defined _%%a (
  9.    set /a "c=_%%a-1"
  10.        for /l %%i in (1,1,!c!) do (
  11.            set /a "b=%%i+1"
  12.            for /l %%j in (!b!,1,!_%%a!) do (
  13.            if !_%%a_%%i! gtr !_%%a_%%j! set/a "_%%a_%%j=!_%%a_%%i!,_%%a_%%i=!_%%a_%%j!"
  14.         )
  15.     )
  16.     for /l %%i in (1,1,!_%%a!) do set "var=!var! !_%%a_%%i!"
  17.     echo;%%a!var!&set "var="
  18. )
  19. pause
复制代码

TOP

我也来个..
  1. @echo off&setlocal enabledelayedexpansion
  2. for /f "delims=" %%a in (in.txt) do for %%b in (%%a) do set b=000%%b&set/a_!b:~-1!_!b:~-3!+=1
  3. 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.
  4. pause
复制代码

TOP

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

TOP

返回列表