Global Const ZERO = 0
Global Const ASCENDING_ORDER = 0
Global Const DESCENDING_ORDER = 1Global gIterationsSub BubbleSort(MyArray(), ByVal nOrder As Integer)
Dim Index
Dim TEMP
Dim NextElement NextElement = ZERO
Do While (NextElement < UBound(MyArray))
Index = UBound(MyArray)
Do While (Index > NextElement)
If nOrder = ASCENDING_ORDER Then
If MyArray(Index) < MyArray(Index - 1) Then
TEMP = MyArray(Index)
MyArray(Index) = MyArray(Index - 1)
MyArray(Index - 1) = TEMP
End If
ElseIf nOrder = DESCENDING_ORDER Then
If MyArray(Index) >= MyArray(Index - 1) Then
TEMP = MyArray(Index)
MyArray(Index) = MyArray(Index - 1)
MyArray(Index - 1) = TEMP
End If
End If
Index = Index - 1
gIterations = gIterations + 1
Loop
NextElement = NextElement + 1
gIterations = gIterations + 1
LoopEnd Sub
dim i as integer
dim j as integer
for i=1 to 6
for j=1 to 40
if max(i)<array(j) then0D
max(i)=array(j)
array(j)=0
end if
next j
next i
================================================================CSDN 论坛助手 Ver 1.0 B0402提供下载。 改进了很多,功能完备!★ 浏览帖子速度极快![建议系统使用ie5.5以上]。 ★ 多种帖子实现界面。
★ 保存帖子到本地[html格式]★ 监视您关注帖子的回复更新。
★ 可以直接发贴、回复帖子★ 采用XML接口,可以一次性显示4页帖子,同时支持自定义每次显示帖子数量。可以浏览历史记录!
★ 支持在线检测程序升级情况,可及时获得程序更新的信息。★★ 签名 ●
可以在您的每个帖子的后面自动加上一个自己设计的签名哟。Http://www.ChinaOK.net/csdn/csdn.zip
Http://www.ChinaOK.net/csdn/csdn.rar
Http://www.ChinaOK.net/csdn/csdn.exe [自解压]
每个的值的范围从1-6
现在想让该数组由大到小排序,然后从大到小找出大于4的数组,如果超过六个则取前六个,如果小于六个,那么有几个取几个,因为最后我是要去匹配,假设有三个
array(1),array(14),array(28)这时候我就会到数据库检索... where job in (1,14,28)
所以我要记录下数组的下标,in后面最多有六个,也就是小于等于6个,我怎么处理好,我想不出好的办法,请各位兄弟帮我写写看,一定送分
dim i as integer
dim j as integer
for i=1 to 6
for j=1 to 40
if max(i)<array(j) then0D
max(i)=array(j)
array(j)=0
end if
next j
if max(i)<4 then exit for
next istrRange=""
for i=1 to 6
if max(i)>=4 then
strRange=strRange & max(i) &","
else
exit for
endif
nextstrRange=left(strRange,len(strRange)-1)"...where job in (" & strRange &")"
你看着,
intProFour()存放大于4的数据
intProFourMark()存放大于4数据在原始数组中的下标
本来也可以用二维数组的,我懒得动了.^_^
两个数组中的元素个数相同并且一一对应
用的时候从中间取出数据就可以了.