中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net  论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

游客:  注册 | 登录 | 命令行 | 会员 | 搜索 | 上传 | 帮助 »
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [原创]***********快速排序*************
作者:
标题: [原创]***********快速排序************* 上一主题 | 下一主题
s11ss
银牌会员





积分 2098
发帖 566
注册 2007-9-11
状态 离线
『楼 主』:  [原创]***********快速排序*************

@echo off setlocal enabledelayedexpansion :::::::::::::::::::::::::::::::::::::::::Quick 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 call :oo 1 %nx% goto :p :oo set /a aa=%1 set /a bb=%2 if %aa% lss %bb% ( call :partition %aa% %bb% set /a jj=!i!-1 call :oo %aa% !jj! set /a ii=!i!+1 call :oo !ii! %bb% ) goto :eof :partition set /a i=%1 set /a j=%2 set /a temporary=!n%i%! :cir :cr2l if %temporary% leq !n%j%! ( if %i% lss %j% (set /a j-=1 && goto :cr2l) ) if %i% lss %j% (set /a n%i%=!n%j%! & set /a i+=1) :cl2r if %temporary% geq !n%i%! ( if %i% lss %j% (set /a i+=1 && goto :cl2r) ) if %i% lss %j% (set /a n%j%=!n%i%! & set /a j-=1) if not %i% equ %j% goto :cir set /a n%i%=%temporary% goto :eof ::::::::Deal With Numbers:::::::: ::::::::Print The Result:::::::: :p 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-16


2007-9-16 10:02
查看资料  发短消息 网志   编辑帖子  回复  引用回复

请注意:您目前尚未注册或登录,请您注册登录以使用论坛的各项功能,例如发表和回复帖子等。


可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题



论坛跳转: