VB语言高手解决2个文本求交集和求并集问题
发布网友
发布时间:2024-10-22 03:30
我来回答
共1个回答
热心网友
时间:2024-11-14 20:43
'交集求法
Dim nums1(12) as integer={第一组数字}
Dim nums2(12) as integer={第二组数字}
Dim jiao(12),point as integer
for i = 0 to 11
for j=0 to 11
if nums1(i)=nums2(j) then
jiao(point)=nums1(i)
point=point+1
next
next
'并集求法
Dim nums1(12) as integer={第一组数字}
Dim nums2(12) as integer={第二组数字}
Dim bing(24),point=12 as integer
for i = 0 to 11
bing(i)=nums1(i)
next
for j=0 to 11
for k=0 to 11
if nums2(j)=bing(k) then
continue for
else
bing(point)=nums2(j)
point=point+1
end if
next
next