There are 20 randomly generated sequences in it, as follows:
2928326128601232462131283250710027308938740594716691200992050511576
5352129649530193383124730478244772348721985707222557212265817305
217141333532296179938475175265792931789219830308392472584606305
2371620291160322081050531817416284225477019123161801285941026814244
283929972304551060318886921731765136928849135391662294051194618754
1809165929787147057932949630411324311737224509104016550662932273
27396236084901303873154718299242931819623155304661177528921164510335
254221462410491137971033914630292752245114969186002809930190939425
1085287492160525651862932475207612387312368408826675135332406418337
2567810118246621010283281198810903279355871571118961177731143829148
23727111515524141721964179351992331180134926914198081871053303186
378579502856625703213542353218420835730692264021219729654278515442
30215186011014395001656818458819061824708536511543271701327524725
223702764213159156022932717903282522044350522584222768193271431422354
3079720530119542370417125702274761144023302102641160114921224469221
15642298214000242538839193816839550322381321993212316517861828002
13042178002978222022331319116624809338275899045263351248023569
11252165681825711849278422768716060438517976169102391532289954712000
105084292396529699311371735329685626410510259482788519645152723476
29674179062831103792824121564178225289202161443911094228581583531951
It is required to use pure batch processing to output in the order of the size of the sequence, and the positive order is as follows:
13042178002978222022331319116624809338275899045263351248023569
217141333532296179938475175265792931789219830308392472584606305
1809165929787147057932949630411324311737224509104016550662932273
5352129649530193383124730478244772348721985707222557212265817305
15642298214000242538839193816839550322381321993212316517861828002
23727111515524141721964179351992331180134926914198081871053303186
30215186011014395001656818458819061824708536511543271701327524725
105084292396529699311371735329685626410510259482788519645152723476
254221462410491137971033914630292752245114969186002809930190939425
283929972304551060318886921731765136928849135391662294051194618754
378579502856625703213542353218420835730692264021219729654278515442
1085287492160525651862932475207612387312368408826675135332406418337
2371620291160322081050531817416284225477019123161801285941026814244
2567810118246621010283281198810903279355871571118961177731143829148
2928326128601232462131283250710027308938740594716691200992050511576
3079720530119542370417125702274761144023302102641160114921224469221
11252165681825711849278422768716060438517976169102391532289954712000
27396236084901303873154718299242931819623155304661177528921164510335
29674179062831103792824121564178225289202161443911094228581583531951
223702764213159156022932717903282522044350522584222768193271431422354
The value of each row is much more than the maximum value that cmd can calculate.
Requires correct output, no temporary files are generated, and the code is efficient and universal. Complete the question and add points according to your ideas.
batman:
Let me explain the idea first:
This question is indeed a big problem for us, why should we say this? What the poster requires is the sorting of all the super large values in the text.
All values far exceed the maximum value that cmd can calculate, and using conventional comparison methods will not work, which is one of the difficulties;
Second, these values are randomly generated and the total number of characters is uncertain, and may even reach a length of several lines and dozens of lines. For example, character-by-character judgment is used.
The method to make sure the maximum number of characters is, efficiency will be an insurmountable obstacle for such solutions; the third floor owner requires no temporary text to be generated
This is undoubtedly locking the door for the solution of using findstr /o to obtain the largest character in the line.
The summary is as follows:
If the code is general, it needs to obtain the maximum number of characters in the line. One method is the character-by-character method. There are great problems in efficiency using the character-by-character method;
The second method is to use findstr /o to obtain the offset of each line character at one time, and then obtain the maximum number of characters in the line through processing, which is more efficient.
The character-by-character method is much higher, but because using findstr /o alone cannot obtain the text line unline character offset, it must be imposed on the unline.
Enter, use temporary files without destroying the original file.
When writing code, we generally follow four principles: high efficiency, generality, conciseness, and try not to generate temporary files. The first one is
One is efficiency, and the second is universal. As for conciseness and the existence of temporary files, they are not the main considerations, so the primary and secondary relationships are related to me.
The following two solutions are given:
1. Poor generality (it is absolutely fine if numeric characters are all in one line), high efficiency, concise code, no temporary files:
@echo off&setlocal enabledelayedexpansion
for /l %%i in (1,1,80) do set "kong=!kong!#"
for /f %%i in () do (
set "str=%%i%kong%"
set "a=!str:~,80!"
set "a=!a:%%i=!"
set "_!a!%%i=a"
)
for /f "delims==_" %%i in ('set _') do (
set "str=%%i"
echo !str:#=!
)
pause>nul
2. Extremely versatile, average efficiency, generate temporary files, and the code is more complicated:
@echo off&setlocal enabledelayedexpansion
set "max=0"&set "a=0"
for /f %%i in () do echo %%i>>
echo.>>
for /f "tokens=1,2* delims=:" %%i in ('findstr /n /o .* ') do (
set /a n+=1,m=n-1
set "num=%%i"&set "_!n!=%%j"&set "#%%i=%%k"
if !m! gtr 0 set /a a=_!n!-_!m!-2
if !max! lss !a! set "max=!a!"
)
set /a num-=1
for /l %%i in (1,1,%max%) do set "kong=!kong!#"
for /l %%i in (1,1,%num%) do (
set "str=!#%%i!%kong%"
set "a=!str:~,%max%!"
call,set "a=%%a:!#%%i!=%%"
set ".!a!!#%%i!=a"
)
for /f "delims==." %%i in ('set .') do (
set "str=%%i"
echo !str:#=!
)
del /q &pause>nul
pusofalse:
@echo off&setlocal enabledelayedexpansion
set m=0
for /f "tokens=1,* delims=:" %%a in ('findstr/o .* ') do (
set/a n+=1,l=n-1,y+=1
set ..!n!=%%a
set ##!y!=%%b
if !n! geq 2 (
call,set/a s=%%..!n!%%-%%..!l!%%-2,line+=1
call,set "_!s!=%%_!s!%%%%##!line!%% "
if !s! geq !m! set m=!s!
)
)
for /f "skip=1 delims=:" %%a in ('^(echo !##%y%!^&echo.^)^|findstr/o .*') do set/a final=%%a-3
call,set "_%final%=%%_!final!%% !##%y%!"
if %final% geq !m! set m=%final%
for /l %%a in (1 1 %m%) do (
if defined _%%a (
for %%i in (!_%%a!) do set -%%i=faith
for /f "delims=-=" %%s in ('set -') do (
echo %%s
set "-%%s="
)
)
)
pause>nul
2928326128601232462131283250710027308938740594716691200992050511576
5352129649530193383124730478244772348721985707222557212265817305
217141333532296179938475175265792931789219830308392472584606305
2371620291160322081050531817416284225477019123161801285941026814244
283929972304551060318886921731765136928849135391662294051194618754
1809165929787147057932949630411324311737224509104016550662932273
27396236084901303873154718299242931819623155304661177528921164510335
254221462410491137971033914630292752245114969186002809930190939425
1085287492160525651862932475207612387312368408826675135332406418337
2567810118246621010283281198810903279355871571118961177731143829148
23727111515524141721964179351992331180134926914198081871053303186
378579502856625703213542353218420835730692264021219729654278515442
30215186011014395001656818458819061824708536511543271701327524725
223702764213159156022932717903282522044350522584222768193271431422354
3079720530119542370417125702274761144023302102641160114921224469221
15642298214000242538839193816839550322381321993212316517861828002
13042178002978222022331319116624809338275899045263351248023569
11252165681825711849278422768716060438517976169102391532289954712000
105084292396529699311371735329685626410510259482788519645152723476
29674179062831103792824121564178225289202161443911094228581583531951
It is required to use pure batch processing to output in the order of the size of the sequence, and the positive order is as follows:
13042178002978222022331319116624809338275899045263351248023569
217141333532296179938475175265792931789219830308392472584606305
1809165929787147057932949630411324311737224509104016550662932273
5352129649530193383124730478244772348721985707222557212265817305
15642298214000242538839193816839550322381321993212316517861828002
23727111515524141721964179351992331180134926914198081871053303186
30215186011014395001656818458819061824708536511543271701327524725
105084292396529699311371735329685626410510259482788519645152723476
254221462410491137971033914630292752245114969186002809930190939425
283929972304551060318886921731765136928849135391662294051194618754
378579502856625703213542353218420835730692264021219729654278515442
1085287492160525651862932475207612387312368408826675135332406418337
2371620291160322081050531817416284225477019123161801285941026814244
2567810118246621010283281198810903279355871571118961177731143829148
2928326128601232462131283250710027308938740594716691200992050511576
3079720530119542370417125702274761144023302102641160114921224469221
11252165681825711849278422768716060438517976169102391532289954712000
27396236084901303873154718299242931819623155304661177528921164510335
29674179062831103792824121564178225289202161443911094228581583531951
223702764213159156022932717903282522044350522584222768193271431422354
The value of each row is much more than the maximum value that cmd can calculate.
Requires correct output, no temporary files are generated, and the code is efficient and universal. Complete the question and add points according to your ideas.
batman:
Let me explain the idea first:
This question is indeed a big problem for us, why should we say this? What the poster requires is the sorting of all the super large values in the text.
All values far exceed the maximum value that cmd can calculate, and using conventional comparison methods will not work, which is one of the difficulties;
Second, these values are randomly generated and the total number of characters is uncertain, and may even reach a length of several lines and dozens of lines. For example, character-by-character judgment is used.
The method to make sure the maximum number of characters is, efficiency will be an insurmountable obstacle for such solutions; the third floor owner requires no temporary text to be generated
This is undoubtedly locking the door for the solution of using findstr /o to obtain the largest character in the line.
The summary is as follows:
If the code is general, it needs to obtain the maximum number of characters in the line. One method is the character-by-character method. There are great problems in efficiency using the character-by-character method;
The second method is to use findstr /o to obtain the offset of each line character at one time, and then obtain the maximum number of characters in the line through processing, which is more efficient.
The character-by-character method is much higher, but because using findstr /o alone cannot obtain the text line unline character offset, it must be imposed on the unline.
Enter, use temporary files without destroying the original file.
When writing code, we generally follow four principles: high efficiency, generality, conciseness, and try not to generate temporary files. The first one is
One is efficiency, and the second is universal. As for conciseness and the existence of temporary files, they are not the main considerations, so the primary and secondary relationships are related to me.
The following two solutions are given:
1. Poor generality (it is absolutely fine if numeric characters are all in one line), high efficiency, concise code, no temporary files:
@echo off&setlocal enabledelayedexpansion
for /l %%i in (1,1,80) do set "kong=!kong!#"
for /f %%i in () do (
set "str=%%i%kong%"
set "a=!str:~,80!"
set "a=!a:%%i=!"
set "_!a!%%i=a"
)
for /f "delims==_" %%i in ('set _') do (
set "str=%%i"
echo !str:#=!
)
pause>nul
2. Extremely versatile, average efficiency, generate temporary files, and the code is more complicated:
Copy the codeThe code is as follows:
@echo off&setlocal enabledelayedexpansion
set "max=0"&set "a=0"
for /f %%i in () do echo %%i>>
echo.>>
for /f "tokens=1,2* delims=:" %%i in ('findstr /n /o .* ') do (
set /a n+=1,m=n-1
set "num=%%i"&set "_!n!=%%j"&set "#%%i=%%k"
if !m! gtr 0 set /a a=_!n!-_!m!-2
if !max! lss !a! set "max=!a!"
)
set /a num-=1
for /l %%i in (1,1,%max%) do set "kong=!kong!#"
for /l %%i in (1,1,%num%) do (
set "str=!#%%i!%kong%"
set "a=!str:~,%max%!"
call,set "a=%%a:!#%%i!=%%"
set ".!a!!#%%i!=a"
)
for /f "delims==." %%i in ('set .') do (
set "str=%%i"
echo !str:#=!
)
del /q &pause>nul
pusofalse:
Copy the codeThe code is as follows:
@echo off&setlocal enabledelayedexpansion
set m=0
for /f "tokens=1,* delims=:" %%a in ('findstr/o .* ') do (
set/a n+=1,l=n-1,y+=1
set ..!n!=%%a
set ##!y!=%%b
if !n! geq 2 (
call,set/a s=%%..!n!%%-%%..!l!%%-2,line+=1
call,set "_!s!=%%_!s!%%%%##!line!%% "
if !s! geq !m! set m=!s!
)
)
for /f "skip=1 delims=:" %%a in ('^(echo !##%y%!^&echo.^)^|findstr/o .*') do set/a final=%%a-3
call,set "_%final%=%%_!final!%% !##%y%!"
if %final% geq !m! set m=%final%
for /l %%a in (1 1 %m%) do (
if defined _%%a (
for %%i in (!_%%a!) do set -%%i=faith
for /f "delims=-=" %%s in ('set -') do (
echo %%s
set "-%%s="
)
)
)
pause>nul