cmd.exe(批处理)脚本中的数组,链接列表和其他数据结构

cmd.exe(批处理)脚本中的数组,链接列表和其他数据结构

我正在玩cmd.exe,但在它的帮助下我没有找到任何信息,如何定义数组。

我发现,如何定义简单变量:

set a=10echo %a%

但是,我想创建数组,链表等...

那么,它能否在cmd.exe中使用(我的意思是:cmd.exe中是否存在任何数组关键字?)

我想实现一些算法:

  • 泡泡排序

  • 快速排序

  • 侏儒排序

等等...

所以,我也想知道,Cmd.exe是否有引用或实例,结构等?

导致其帮助不完整:/?

可以通过图灵机定义将Cmd.exe定义为完整吗?(图灵完成)


阿晨1998
浏览 2104回答 4
4回答

FFIVE

我刚才使用伪数组批量生成了冒泡排序。不确定为什么要使用它(虽然我会承认在另一个批处理文件中这样做),因为随着列表大小的增加它变得非常慢。更多的是为自己设置一个小挑战。 有人可能会觉得这很有用。:: Bubblesort:: Horribly inefficient for large lists:: Dave Johnson implementation 05/04/2013@echo offsetlocal enabledelayedexpansion:: Number of entries to populate and sortset maxvalue=50:: Fill a list of vars with Random numbers and print themfor /l %%a in (1,1,%maxvalue%) do (    set /a tosort%%a=!random!):: echo themset tosort:: Commence bubble sortEcho Sorting...set /a maxvalue-=1set iterations=0for /l %%a in (%maxvalue%,-1,1) do ( REM Decrease by 1 the number of checks each time as the top value will always float to the end    set hasswapped=0        for /l %%b in (1,1,%%a) do (            set /a next=%%b+1            set next=tosort!next!            set next=!next!            call :grabvalues tosort%%b !next!            rem echo comparing tosort%%b = !tosortvalue! and !next! = !nextvalue!            if !nextvalue! LSS !tosortvalue! (            rem set /a num_of_swaps+=1            rem echo Swapping !num_of_swaps!                set !next!=!tosortvalue!                set tosort%%b=!nextvalue!                set /a hasswapped+=1            )        )    set /a iterations+=1    if !hasswapped!==0 goto sorted)goto:eof:grabvaluesset tosortvalue=!%1!set nextvalue=!%2!goto:eof:sorted::nice one our kidset tosortvalue=echo Iterations required: %iterations%set tosortendlocal
打开App,查看更多内容
随时随地看视频慕课网APP