VB统计一组数在另一组数中出现的次数
来源:学生作业帮 编辑:作业帮 分类:数学作业 时间:2024/05/22 00:44:36
VB统计一组数在另一组数中出现的次数
Private Sub Form_click()
Dim a As Variant,b(32) As Integer,c() As Integer,d() As String
Dim i As Long,j As Long
a = Array(2,5,6,12,14,28,4,6,12,30,31,32,2,8,13,28,29,30,1,2,5,16,20,26,1,7,8,12,16,21)
For i = 0 To 32
b(i) = i + 1
Next
ReDim c(UBound(b))
For i = 0 To UBound(b)
For j = 0 To UBound(a)
If b(i) = a(j) Then c(i) = c(i) + 1
Next
Next
ReDim Preserve d(x) As String
For i = 0 To UBound(c)
If c(i) > UBound(d) Then ReDim Preserve d(c(i)) As String
d(c(i)) = d(c(i)) & b(i) & " "
Next
Cls
For i = 0 To UBound(d)
Print d(i) & " 出现" & i & "次"
Next
End Sub
再问: 亲不好意思,没说清楚,第一组数的字数不固定(text1.text),但一定得是两两一组(带一空格),如05 06 07 ...........
再答: Private Sub Form_click() Dim a As Variant, b(32) As String, c() As Integer, d() As String Dim i As Long, j As Long Text1.Text = "02 05 06 12 14 28 04 06 12 30 31 32 02 08 13 28 29 30 01 02 05 16 20 26 01 07 08 12 16 21" a = Split(Text1.Text, " ") For i = 0 To 32 b(i) = Format(i + 1, "00") Next ReDim c(UBound(b)) For i = 0 To UBound(b) For j = 0 To UBound(a) If b(i) = a(j) Then c(i) = c(i) + 1 Next Next ReDim Preserve d(x) As String For i = 0 To UBound(c) If c(i) > UBound(d) Then ReDim Preserve d(c(i)) As String d(c(i)) = d(c(i)) & b(i) & " " Next Cls For i = 0 To UBound(d) Print d(i) & " 出现" & i & "次" Next End Sub
Dim a As Variant,b(32) As Integer,c() As Integer,d() As String
Dim i As Long,j As Long
a = Array(2,5,6,12,14,28,4,6,12,30,31,32,2,8,13,28,29,30,1,2,5,16,20,26,1,7,8,12,16,21)
For i = 0 To 32
b(i) = i + 1
Next
ReDim c(UBound(b))
For i = 0 To UBound(b)
For j = 0 To UBound(a)
If b(i) = a(j) Then c(i) = c(i) + 1
Next
Next
ReDim Preserve d(x) As String
For i = 0 To UBound(c)
If c(i) > UBound(d) Then ReDim Preserve d(c(i)) As String
d(c(i)) = d(c(i)) & b(i) & " "
Next
Cls
For i = 0 To UBound(d)
Print d(i) & " 出现" & i & "次"
Next
End Sub
再问: 亲不好意思,没说清楚,第一组数的字数不固定(text1.text),但一定得是两两一组(带一空格),如05 06 07 ...........
再答: Private Sub Form_click() Dim a As Variant, b(32) As String, c() As Integer, d() As String Dim i As Long, j As Long Text1.Text = "02 05 06 12 14 28 04 06 12 30 31 32 02 08 13 28 29 30 01 02 05 16 20 26 01 07 08 12 16 21" a = Split(Text1.Text, " ") For i = 0 To 32 b(i) = Format(i + 1, "00") Next ReDim c(UBound(b)) For i = 0 To UBound(b) For j = 0 To UBound(a) If b(i) = a(j) Then c(i) = c(i) + 1 Next Next ReDim Preserve d(x) As String For i = 0 To UBound(c) If c(i) > UBound(d) Then ReDim Preserve d(c(i)) As String d(c(i)) = d(c(i)) & b(i) & " " Next Cls For i = 0 To UBound(d) Print d(i) & " 出现" & i & "次" Next End Sub
VB统计一组数在另一组数中出现的次数
如何统计一组整数中出现次数最多的数?
怎么用电子表格统计一个数出现下一行另一个数的出现次数?
excel 统计次数,5列为一组,要统计出现其中三个数字的次数(如统计 1 5 6 在这几组中出现的次数)
vb统计在一个文本框内各英文单词出现的次数
VB中在一段英文字母中 统计哪个字母出现的最多,次数是多少 有段代码求解释!
Excel中如何统计某个数出现的次数
EXCEL如何统计各个数出现的次数
在 word文档里如何统计英文单词出现的次数
VB随机产生1000个10-99之间的随机数,统计出现次数最多的数是哪几个?
VB编写程序 用计算机模拟掷骰子游戏.编写程序统计掷N次后各点数出现的次数
EXCEL 统计连续数字出现的次数