In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "how to solve the problem of numerical ordering in programming development". The content is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn the article "how to solve the problem of numerical sorting in programming development".
The one with the problem:
Master the sorting skills between any sequence of numbers
Problem solving requirements:
The code is universal and efficient.
Keep it as simple as possible
Try not to generate temporary files
Bonus points rule:
1 unique benchmark score of 5 points
2 code efficiency, general benchmark score 4 points
3 skill superb benchmark score 3 points
4 code simplicity benchmark score 2 points
5 perfect code plus 15 points
The topics are as follows:
Give any set of sequence, positive sequence output, such as:
3 2008 11 19 777 23 2014 453 789 51
Output: 3 11 19 23 51 453 777 789 2008 2014
Description:
Don't worry about extra-large numbers, the given series is full of integer values.
Dishuo:
The code is as follows:
Cls&@echo off&setlocal enabledelayedexpansion
Set "strings=3 2008 11 19 777 23 2014 453 789 51"
Echo strings%
Set/a nasty 0
For I in (strings%) do (
Set/a naughty 1
Set num [! n!] =% I
)
Call: quicksort num 1% n%
For / l%% I in (1JI% n%) do echo! num [% I]!
Pause&goto:eof
: QuickSort
:: code by dishuostec
:: use call: quicksort arrary low high
Set "ARR=%1"
Set/a dep=0
Call: QS 2 3
Goto:eof
: QS
Set/a dep+=1,lTmpLow=%1,lTmpHi=%2,Low=%1,Hi=%2
If% Hi% leq% Low% set/a dep-=1&goto: eof
Set/a lTmpMid= (Low+Hi) / 2
Call set/a vTempVal=%%%ARR% [! lTmpMid!]%
: qsMainLoop
If! lTmpLow! Leq! lTmpHi! (
: qsLoop1
Call set/a vVal=%%%ARR% [! lTmpLow!]%
If! vVal! Lss! vTempVal! If! lTmpLow! Lss! Hi! Set/a lTmpLow+=1& goto qsLoop1
: qsLoop2
Call set/a vVal=%%%ARR% [! lTmpHi!]%
If! vTempVal! Lss! vVal! If! Low! Lss! lTmpHi! Set/a lTmpHi-=1&goto qsLoop2
: qsSwap
If! lTmpLow! Leq! lTmpHi! (
Call set/a vTmpHold=%%%ARR% [! lTmpLow!]%
Call set/an ARR% [! lTmpLow!] =% ARR% [! lTmpHi!]%
Set/a% ARR% [! lTmpHi!] = vTmpHold
Set/a lTmpLow+=1,lTmpHi-=1
)
Goto qsMainLoop
)
Set/a lTmpLow [% dep%] = lTmpLow,Hi [% dep%] = Hi
If% Low% lss% lTmpHi% call: QS% Low%% lTmpHi%
Call set lTmpLow=%%lTmpLow [! dep!]% & call set Hi=%%Hi [! dep!]%
If% lTmpLow% lss% Hi% call: QS% lTmpLow%% Hi%
Set/a dep-=1&goto: eof
Terse:
The code is as follows:
@ echo off&setlocal enabledelayedexpansion
Set str=3 2008 11 19 777 23 2014 453 789 51
For I in (str%) do (
Set str=0000000000%%i
Set.! str:~-10!! customers%% I
)
For / f "tokens=2 delims=="% I in ('set.') Do set/p=%%i nul
MKL:
The code is as follows:
@ echo off&setlocal enabledelayedexpansion
Set "pendant 3 2008 11 19 777 23 2014 453 789 51"
For I in (p) do (
Set twee1
For r in (p%) do (
If I gtr r set / a tweets
)
Set! tasking%% I
)
Echo! 1!! 2!! 3!! 4!! 5!! 6!! 7!! 8!! 9!! 10!
Pause
523066680:
The code is as follows:
@ echo off
Setlocal enabledelayedexpansion
Set hang=3 2008 11 19 777 23 2014 453 789 51 3 3 4 2014
Set nasty 0
For an in (hang%) do (
Set / a num=1,n+=1
For% b in (% hang%) do (
If a gtr b set / a num+=1
)
Call: next! num!
Set! numbness% a
)
For / l% an in (1JI% n%) do echo!% a!
Pause
Goto: eof
: next
If defined% num% (set / a num+=1 & goto: next)
These are all the contents of this article entitled "how to solve the problem of numerical sorting in programming Development". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.