China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-22 19:46
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] Numerical Sorting (Difficulty: Difficult, Problem Solved) DigestI View 12,668 Replies 31
Floor 31 Posted 2008-05-04 19:09 ·  中国 湖南 株洲 电信
金牌会员
★★★★
永远的学习者
Credits 3,105
Posts 1,276
Joined 2008-03-08 13:00
18-year member
UID 112398
Gender Male
Status Offline
I have 31st floor code still not considering the situation where there are n same digits in front of the value, modify again as follows:

@echo off&setlocal enabledelayedexpansion
set "str=%random% %random% -%random% %random% %random% -%random% "
for %%i in (%str%) do call,set var=!var! n%%in
for %%i in (%var%) do set a=%%i&call :lp
echo !var:n=!
pause>nul&goto :eof
:lp
for %%i in (%var%) do (
set b=%%i&set b=!b:~1,-1!&set c=%a:~1,-1%
if !b! lss !c! (
set var=!var:%a% =!
set var=!var:%%i=%%i %a%!
)
)
批处理之家新域名:www.bathome.net
Floor 32 Posted 2008-05-04 19:58 ·  中国 湖南 娄底 电信
银牌会员
★★★
Credits 2,268
Posts 879
Joined 2006-12-19 16:23
19-year member
UID 73968
Gender Male
Status Offline
The code after the tag seems to have a logical problem. Please test the following numbers.
set "str=111 2 555 111 2 -8 0 -9 9 5 0"
致精致简!
Forum Jump: