⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 冒泡排序.txt

📁 s11ss写的批处理。他把很多C语言中经典的例子都用批处理实现了
💻 TXT
字号:
@echo off
setlocal enabledelayedexpansion

:::::::::::::::::::::::::::::::::::::::::Bubble Sort:::::::::::::::::::::::::::::::::::::::::


::::::::Get Original Numbers::::::::
echo Please input some numbers separated from "," , like 2007,9,14,88:
set /a s=0
set /p str=
set /a len=0
set /a nx=0
:c
call set word=%%str:~%len%,1%%
set /a len+=1
if "%word%" equ "," (set /a nx+=1 & call :e)
if not "%word%" equ "" (goto :c)
set /a nx+=1
call :e
goto :o
:e
set /a sn=%len%-%s%-1
call set n%nx%=%%str:~%s%,%sn%%%
set /a s=%len%
goto :eof
::::::::Get Original Numbers::::::::

::::::::Deal With Numbers::::::::
:o
set /a i=1
:q
set changed=False
set /a j=%nx%
:v
set /a k=%j%-1
if !n%k%! gtr !n%j%! (
        set /a temporary=!n%k%!
        set /a n%k%=!n%j%!
        set /a n%j%=!temporary!
        set changed=True
)
set /a j-=1
if %j% geq %i% (
        if not %j% equ 1 (
                goto :v
                                         )
                           )
if %changed% equ False goto :p
set /a i+=1
if %i% lss %nx% goto :q
::::::::Deal With Numbers::::::::

::::::::Print The Result::::::::
:p
::set /a qi=%maxinc%+1
::set /a zhi=%nx%+%maxinc%
for /l %%c in (1,1,%nx%) do (set str2=!str2!!n%%c! )
echo.
echo The numbers after sorting are:
echo !str2!
echo.
echo Press Any Key To Exit...
pause>nul
goto :eof
::::::::Print The Result::::::::


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::s11ss
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::2007-9-15 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -