作者fumizuki (蒙面加菲狮)
看板Visual_Basic
标题Re: [VB6 ] 联集与交集的运算
时间Fri May 11 07:38:19 2007
※ 引述《stormbird (单眼皮)》之铭言:
: 那请问我要如何改阿,我里面也忘了写到有当n1(i) = n2(i) = n4(i)的条件,
: 如过我要加的话,那要加在哪阿??可以指点一下吗??
Dim i As Integer, j As Integer, Exists As Boolean
Dim a(10) As Integer, b(10) As Integer
'要做差集运算的两个阵列
Dim c() As Integer, n As Integer
n = -1
'寻找 a 在 b 中不存在的
For i = 0 To UBound(a)
Exists = False
For j = 0 To Ubound(b)
If a(i) = b(j) then Exists = True: Exit For
Next
If Not Exists Then
n = n + 1: Redim Preserve c(n)
c(n) = a(i)
End If
Next
'寻找 b 在 a 中不存在的
For i = 0 To UBound(b)
Exists = False
For j = 0 To Ubound(a)
If b(i) = a(j) then Exists = True: Exit For
Next
If Not Exists Then
n = n + 1: Redim Preserve c(n)
c(n) = b(i)
End If
Next
'c 阵列是差集运算的结果
没验证过,不知道有没有写错:p
--
▃▅▇▆▄ ▆▂▃ `
逝去感情如何能留住,半点痴情遗留殊不易,██▅▇▄▃ ▇▃▂" .
█████████▃i ▁▄▇
更多凄凄惨惨的遭遇…………██▆▃ █▅▆▃ˍ▄*
◢ ▂█▄▇▅▂▌.
我不知道,王~八~蛋~~! ▂▆███ █▄▃ 。fumizuki。Check。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 123.194.224.174
※ 编辑: fumizuki 来自: 123.194.224.174 (05/11 07:38)