一、冒泡法:- @echo off&setlocal enabledelayedexpansion
- for %%i in (3 2008 11 19 777 23 2014 453 789 51) do set "str=!str! #%%i#"
- set "var=%str%"
- for %%a in (%str%) do (
- for %%i in (!var!) do (
- set "a=%%a"&set "b=%%i"
- set "a=!a:#=!"&set "b=!b:#=!"
- if !a! gtr !b! (
- set "var=!var:%%a =!"
- set "var=!var:%%i=%%i %%a!"
- )
- )
- )
- echo %var:#=%&pause>nul
复制代码 二、补位法:- @echo off&setlocal enabledelayedexpansion
- for /l %%i in (1,1,80) do set "bw=!bw!0"
- for %%i in (3 2008 11 19 777 23 2014 453 789 51) do (
- set "str=%bw%%%i"
- set "_!str:~-80!=%%i"
- )
- for /f "tokens=2 delims==" %%i in ('set _') do set /p=%%i <nul
- pause>nul
复制代码
[ 本帖最后由 batman 于 2008-8-22 14:18 编辑 ] |