iT邦幫忙

0

Day 9: 集合(Set)操作與應用

  • 分享至 

  • xImage
  •  

集合(Set)是一種無序且不重複的元素集合。

  1. 創建集合
    集合使用大括號 {} 創建,並且不允許重複元素
    https://ithelp.ithome.com.tw/upload/images/20241021/20169519U3zWTlvw9x.png

https://ithelp.ithome.com.tw/upload/images/20241021/20169519eRejCQM4sH.png
2. 新增與刪除集合元素
https://ithelp.ithome.com.tw/upload/images/20241021/20169519Km1qRrgIJN.png
https://ithelp.ithome.com.tw/upload/images/20241021/201695199CxX7Ags0a.png
3. 集合運算
集合支援集合運算,如聯集、交集和差集
https://ithelp.ithome.com.tw/upload/images/20241021/20169519Ti3w91wANq.png

https://ithelp.ithome.com.tw/upload/images/20241021/20169519uQuL3NsjFI.png
集合是一種適合進行無重複元素處理的資料結構。提供了高效的集合運算能力。


尚未有邦友留言

立即登入留言