28,391
社区成员
发帖
与我相关
我的任务
分享
<%
DIM a(9) , b(9,1)
a(0)=1
a(1)=1
a(2)=2
a(3)=3
a(4)=1
a(5)=2
a(6)=3
a(7)=4
a(8)=5
a(9)=6
For i=0 To 9
b(i,0)=i
for j=0 to 9
if b(i,0)=a(j) then b(i,1)= b(i,1)+1
next
next
For i=0 To 9
if b(i,0)>0 and b(i,1)>0 then Response.Write b(i,0) & "," & b(i,1) & "<BR>"
next
%>
<%
a = Array(1, 1, 2, 3, 1, 2, 3, 4, 5, 6)
Set c = CreateObject("Scripting.Dictionary")
a1 = 0: a2 = 0
For i = 0 To UBound(a)
If c.Exists(a(i)) Then
d = CInt(c.Item(a(i)))
d = d + 1
c.Item(a(i)) = CStr(d)
Else
c.Add a(i), 1
d = 1
End If
If d > a2 Then
a1 = a(i): a2 = d
End If
Next
For Each x In c
response.write x & " = " & c.Item(x)
Next
response.write "最多的是:"; a1 & ",出现了" & a2 & "次"
%>
DIM a(9)
a(0)=1
a(1)=1
a(2)=2
a(3)=3
a(4)=1
a(5)=2
a(6)=3
a(7)=4
a(8)=5
a(9)=6
Set rs = CreateObject("ADODB.Recordset")
rs.CursorLocation = 3
rs.Fields.Append "val", 3
rs.Fields.Append "cnt", 3
rs.Open
rs.AddNew
rs("val") = a(0)
rs("cnt") = 1
rs.Update
For i=1 To UBound(a)
rs.MoveFirst
rs.Find "val=" & a(i)
If Not rs.EOF Then
rs("cnt") = rs("cnt") + 1
Else
rs.AddNew
rs("val") = a(i)
rs("cnt") = 1
End If
rs.Update
Next
rs.Sort = "cnt desc"
rs.MoveFirst
i=1
s = ""
Do While Not rs.EOF
s = s & i & ". " & rs("val") & " " & rs("cnt") & VbCrLf & "<br>"
rs.MoveNext
i = i + 1
Loop
Response.Write s