昨天要求2个数组并集的进来cc。

 1   
 2option explicit   
 3function kickthesame(ByRef arrname)   
 4dim c   
 5dim mcount   
 6dim j   
 7dim i   
 8dim currentc   
 9dim fcount   
10mcount=ubound(arrname)   
11currentc=0   
12fcount=0   
13redim c(mcount)   
14for i=0 to ubound(arrname)-1   
15if arrname(i)=arrname(i+1) then   
16mcount=mcount-1   
17c(currentc)=arrname(i)   
18currentc=currentc+1   
19fcount=fcount+1   
20i=i+1   
21else   
22c(currentc)=arrname(i)   
23currentc=currentc+1   
24end if   
25next   
26redim preserve c(ubound(arrname)-fcount)   
27'for i=0 to ubound(c)   
28'Response.Write c(i)&"

<br/>

 1"   
 2'next   
 3kickthesame=c   
 4end function   
 5  
 6function combine(arrname1,arrname2)   
 7dim mcount   
 8dim mcount1   
 9mcount=0   
10mcount1=0   
11dim c   
12dim acount   
13dim bcount   
14acount=0   
15bcount=0   
16while(acount

<ubound(arrname1) <ubound(arrname2))="" acount="acount+1" and="" bcount="bcount+1" c(mcount)="" c(mcount-1)="arrname1(acount)" else="" end="" if="" if(arrname1(acount)="" if(arrname1(acount)<arrname2(bcount))="" mcount="1" preserve="" redim="" then="">arrname2(bcount)) then
mcount=mcount+1
if mcount=1 then
redim c(mcount)
else
redim preserve c(mcount)
end if
c(mcount-1)=arrname1(acount)
bcount=bcount+1
end if
wend

if acount=ubound(arrname1) then
'Response.Write "bcount"&amp;bcount&amp;"<br/>"
'for i=0 to ubound(arrname2)
'Response.Write arrname2(i)&amp;"<br/>"
'next
mcount1=mcount
mcount=ubound(c)+ubound(arrname2)-bcount
redim preserve c(mcount)
for i=mcount-2 to ubound(c)-1
c(i)=b(bcount+i-mcount+ubound(arrname2)+1)
next
end if

if bcount=ubound(arrname2) then
mcount1=mcount
mcount=ubound(c)+ubound(arrname1)-bcount
redim preserve c(mcount)
for i=mcount-2 to ubound(c)-1
c(i)=a(i+mcount-ubound(c)+1)
next
end if

for i=0 to ubound(c)
Response.Write c(i)&amp;"<br/>"
next

combine=c
end function

function bubblesort(ByRef arrname,length)
dim pass
pass=1
dim exchange
exchange=1
while(pass<length -1="" and="" arrname,pass,byref="" call="" dim="" end="" exchange="0" exchange)="" for="" function="" functionexchange(arrname,pass,exchange)="" functionexchange(byref="" i="ubound(arrname)-1" if(arrname(i-1)="" next="" pass="" step="" temp="" to="" ubound(arrname)="" wend="">arrname(i)) then
temp=arrname(i)
arrname(i)=arrname(i-1)
arrname(i-1)=temp
exchange=1
end if
next
end function

dim a(6)
dim b(6)
dim i
for i=0 to 2
a(i)=i
next
for i=3 to 5
a(i)=5-i
next
for i=0 to 2
b(i)=i+2
next
for i=3 to 5
b(i)=7-i
next

Response.Write "before combine"&amp;"<br/>"
for i=0 to ubound(a)-1
Response.Write "a"&amp;i&amp;"="&amp;a(i)&amp;"<br/>"
next
for i=0 to ubound(b)-1
Response.Write "b"&amp;i&amp;"="&amp;b(i)&amp;"<br/>"
next
Response.Write "after combine"&amp;"<br/>"

call bubblesort(a,5)
call bubblesort(b,5)

call combine(kickthesame(a),kickthesame(b))

Published At
Categories with Web编程
Tagged with
comments powered by Disqus