Ñ§Ï°Íø¿¼ÊÔѧϰ×ÊÁÏ

Gzu521.com

¼¸ÖÖ³£ÓÃÅÅÐòËã·¨(asp)

ASP½Ì³Ì   µã»÷£º´Î   ·¢²¼Ê±¼ä£º2006-10-21   ¡¾×ÖÌ壺´ó ÖРС¡¿   À´Ô´£ºGzu521.com
Gzu521.comÎÒµÄÑ§Ï°Íø


dim adata 
adata = array(3,2,4,1,6,0) 

call responsearray(adata, "Ô­À´Ë³Ðò") 
call responsearray(selectsort(adata), "Ñ¡ÔñÅÅÐò") 
call responsearray(quicksort(adata), "¿ìËÙÅÅÐò") 
call responsearray(insertsort(adata), "²åÈëÅÅÐò") 
call responsearray(bubblesort(adata), "ðÅÝÅÅÐò") 


¡¯Ñ¡ÔñÅÅÐò 
function selectsort(a_data) 
    dim i, j, k 
    dim bound, t 
    bound = ubound(a_data) 

    for i = 0 to bound-1 
        k = i 
        for j = i+1 to bound 
            if a_data(k) > a_data(j) then 
                k = j 
            end if 
        next 
        t = a_data(i) 
        a_data(i) = a_data(k) 
        a_data(k) = t 
    next 

    selectsort = a_data 
end function 


¡¯¿ìËÙÅÅÐò 
function quicksort(a_data) 
    dim i, j 
    dim bound, t 
    bound = ubound(a_data) 

    for i = 0 to bound-1 
        for j = i+1 to bound 
            if a_data(i) > a_data(j) then 
                t = a_data(i) 
                a_data(i) = a_data(j) 
                a_data(j) = t 
            end if 
        next 
    next 

    quicksort = a_data 
end function 


¡¯Ã°ÅÝÅÅÐò 
function bubblesort(a_data) 
    dim bound 
    bound = ubound(a_data) 
    dim bsorted, i, t 
    bsorted = false 
     
    do while bound > 0 and bsorted = false 
         
        bsorted = true 
        for i = 0 to bound-1 
            if a_data(i) > a_data(i+1) then 
                t = a_data(i) 
                a_data(i) = a_data(i+1) 
                a_data(i+1) = t 
                bsorted = false 
            end if 
        next 
        bound = bound - 1 
    loop 
     
    bubblesort = a_data 
end function 


¡¯²åÈëÅÅÐò 
function insertsort(a_data) 

^7j0sGo [±¾_ÎÄ_À´_Ô´_ÓÚ_ÎÒ_µÄ_ѧ_ϰ_ÍøÍøÂç±à³ÌASP½Ì³Ì http://Www.GZU521.Com ]^7j0sGo


    dim bound 
    bound = ubound(a_data) 
    dim i, j, t 

    for i = 1 to bound 
        t = a_data(i) 
        j = i 
        do while t<a_data(j-1) and j>0 
            a_data(j) = a_data(j-1) 
            j = j - 1 
        loop 
        a_data(j) = t 
    next 
         
    insertsort = a_data 
end function 

¡¯Êä³öÊý×é 
sub responsearray(a_data, str) 
    dim s 
    s = "" 
    response.write "<b>" & str & "£º</b>" 
    for i = 0 to ubound(a_data) 
        s = s & a_data(i) & "," 
    next 
    s = left(s, len(s)-1) 
    response.write s 
    response.write "<hr>" 
end sub 

%> 

ÔðÈα༭£ºgzu521

ÍøÂç±à³Ì·ÖÀà
ASP½Ì³Ì
.Net½Ì³Ì
Java½Ì³Ì
PHP½Ì³Ì
Êý¾Ý¿â»ù´¡
ACCESS½Ì³Ì
SQL Server½Ì³Ì
MySQL½Ì³Ì
Oracle½Ì³Ì
·ÖÀàÍÆ¼öÐÅÏ¢
¸ü¶à...
´óÀà×îÐÂÎÄÕÂ
¸ü¶à...