# set(集合) 此處的set可與數學裡的集相互呼應,接著要介紹使用方式,要將資料加入set可用insert(),若要移除則可以使用erase(),還有一個成員函式叫count(),可以運用此函式來判斷一個數是否在此集合裡,回傳值為布林值。 ```cpp= #include <iostream> #include <set> using namespace std; int main(){ set<int> my_set; my_set.insert(100); my_set.insert(200); my_set.insert(300); my_set.erase(100); cout << my_set.count(100) << endl;//不存在輸出0 cout << my_set.count(200) << endl;//存在輸出1 return 0; } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up