| 发表于:2007-07-13 10:32:314楼 得分:0 |
private sub command1_click() dim szstr as string dim inti as integer dim icnt as integer dim arry() as string szstr = text2.text inti = len(szstr) for icnt = 0 to len(szstr) - 1 redim preserve arry(icnt) arry(icnt) = asc(mid(szstr, icnt + 1, 1)) next icnt call quicksort(arry(), 0, ubound(arry)) szstr = " " for icnt = 0 to ubound(arry) szstr = szstr & chr(arry(icnt)) next icnt text2.text = szstr end sub sub quicksort(marry() as string, l as integer, r as integer) dim i as integer, j as integer, x as integer, y as integer i = l j = r x = marry((l + r) / 2) while (i <= j) while (marry(i) < x and i < r) i = i + 1 wend while (x < marry(j) and j > l) j = j - 1 wend if (i <= j) then y = marry(i) marry(i) = marry(j) marry(j) = y i = i + 1 j = j - 1 end if wend if (l < j) then call quicksort(marry(), l, j) if (i < r) then call quicksort(marry(), i, r) end sub | | |
|