※ 引述《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)