易语言交集并集补集源码

易语言交集并集补集源码


2024年4月19日发(作者:)

易语言交集并集补集源码

以下是易语言实现交集、并集、补集的代码示例:

```

// 交集

strA = "12345"

strB = "34567"

intersect = ""

for i = 1 to len(strA)

char = left(strA, i, 1)

if instr(strB, char) <> 0 and instr(intersect, char) = 0 then

intersect = intersect + char

end if

next i

print intersect

// 并集

strA = "12345"

strB = "34567"

union = ""

for i = 1 to len(strA)

char = left(strA, i, 1)

if instr(union, char) = 0 then

union = union + char

end if

next i

for i = 1 to len(strB)

char = left(strB, i, 1)

if instr(union, char) = 0 then

union = union + char

end if

next i

print union

// 补集

strA = "12345"

strB = "34567"

complement = ""

for i = 1 to len(strA)

char = left(strA, i, 1)

if instr(strB, char) = 0 and instr(complement, char) = 0 then

complement = complement + char

end if

next i

print complement

```

注意:以上代码示例只针对字符串进行了操作,如果要对其他

类型的集合进行操作,需要根据具体情况进行修改。


发布者:admin,转转请注明出处:http://www.yc00.com/web/1713460684a2253387.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信