最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

cmd.exe(批處理)腳本中的數(shù)組,鏈接列表和其他數(shù)據(jù)結(jié)構(gòu)

cmd.exe(批處理)腳本中的數(shù)組,鏈接列表和其他數(shù)據(jù)結(jié)構(gòu)

cmd.exe(批處理)腳本中的數(shù)組,鏈接列表和其他數(shù)據(jù)結(jié)構(gòu)我正在玩cmd.exe,但在它的幫助下我沒有找到任何信息,如何定義數(shù)組。我發(fā)現(xiàn),如何定義簡單變量:set a=10echo %a%但是,我想創(chuàng)建數(shù)組,鏈表等...那么,它能否在cmd.exe中使用(我的意思是:cmd.exe中是否存在任何數(shù)組關(guān)鍵字?)我想實現(xiàn)一些算法:泡泡排序快速排序侏儒排序等等...所以,我也想知道,Cmd.exe是否有引用或?qū)嵗Y(jié)構(gòu)等?導致其幫助不完整:/?可以通過圖靈機定義將Cmd.exe定義為完整嗎?(圖靈完成)
查看完整描述

4 回答

?
FFIVE

TA貢獻1797條經(jīng)驗 獲得超6個贊

我剛才使用偽數(shù)組批量生成了冒泡排序。不確定為什么要使用它(雖然我會承認在另一個批處理文件中這樣做),因為隨著列表大小的增加它變得非常慢。更多的是為自己設(shè)置一個小挑戰(zhàn)。 有人可能會覺得這很有用。


:: Bubblesort

:: Horribly inefficient for large lists

:: Dave Johnson implementation 05/04/2013

@echo off

setlocal enabledelayedexpansion

:: Number of entries to populate and sort

set maxvalue=50

:: Fill a list of vars with Random numbers and print them

for /l %%a in (1,1,%maxvalue%) do (

    set /a tosort%%a=!random!

)

:: echo them

set tosort

:: Commence bubble sort

Echo Sorting...

set /a maxvalue-=1

set iterations=0

for /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

:grabvalues

set tosortvalue=!%1!

set nextvalue=!%2!

goto:eof

:sorted

::nice one our kid

set tosortvalue=

echo Iterations required: %iterations%

set tosort

endlocal


查看完整回答
反對 回復 2019-05-22
  • 4 回答
  • 0 關(guān)注
  • 2256 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號