- @echo off
- setlocal enabledelayedexpansion
- ::选择排序法
- echo 共输入10个数
- for /l %%i in (1,1,10) do (
- set /p a_%%i=请输入%%i个数
- set str=!str! !a_%%i!
- )
- echo %str%
- for /l %%i in (1,1,9) do (
- set /a b=%%i+1
- for /l %%j in (!b!,1,10) do (
- if !a_%%i! gtr !a_%%j! (
- set /a t=a_%%i
- set /a a_%%i=a_%%j
- set /a a_%%j=t
- )
- )
- )
- for /l %%i in (1,1,10) do (
- set str1=!str1! !a_%%i!
- )
- echo %str1%
- pause>nul
复制代码
|