{"rsdb":{"rid":"239924","subhead":"","postdate":"0","aid":"165311","fid":"49","uid":"1","topic":"1","content":"
\n

\u672c\u6587\u4ecb\u7ecdset\u7684\u589e\u5220\u67e5\u904d\u5386\u5b9e\u73b0\uff0c\u4f7f\u7528\u4f8b\u5b50\u5982\u4e0b<\/p> \n

\u4e0b\u9762\u7a0b\u5e8f\u7edf\u8ba1\u51fa\u73b0\u7684\u6570\u5b57\u6709\u54ea\u4e9b<\/p> \n

\r\n#include \n  \n   \r\n#include\n   \n     using namespace std; int main() { int numList[6]={1,2,2,3,3,3}; \/\/1.set add set\n    \n      numSet; for(int i=0;i<6;i++) { \/\/2.1insert into set numSet.insert(numList[i]); } \/\/2.travese set for(set\n     \n      ::iterator it=numSet.begin() ;it!=numSet.end();it++) { cout<<*it<<" occurs "<\n      \n       

1\uff0e\u589e\u52a0<\/h1>\n

\u8c03\u7528insert\u6210\u5458\u51fd\u6570\uff0c\u6ce8\u610f\uff0cset\u5305\u542b\u4e0d\u91cd\u590d\u7684\u5173\u952e\u5b57,\u56e0\u6b64\u63d2\u5165\u4e00\u4e2a\u5df2\u7ecf\u5b58\u5728\u7684\u5143\u7d20\u5bf9\u5bb9\u5668\u6ca1\u6709\u5f71\u54cd\uff0e<\/p>\n

 numSet.insert(numList[i]);\r\n<\/pre> \n       

\uff12\uff0e\u904d\u5386<\/h1> \n

\u4f7f\u7528set\n \n ::iterator it\uff1b\u8fed\u4ee3\u5668\u904d\u5386\n <\/int><\/p> \n

\uff13\uff0e\u67e5\u627e<\/h1> \n

\u4f7f\u7528find\u51fd\u6570\u67e5\u627e<\/p> \n

\u4f7f\u7528\u5982<\/p> \n

\r\nif(numSet.find(findNum)!=numSet.end())<\/pre> \n       

find \u8fd4\u56de\u4e00\u4e2a\u8fed\u4ee3\u5668\uff0c\u5982\u679c\u67e5\u627e\u5931\u8d25\u4f1a\u8fd4\u56deend()\u5143\u7d20\uff0c\u5426\u5219\u6210\u529f<\/p> \n

\uff14\uff0e\u5220\u9664<\/h1> \n

erase\u7684\u8fd4\u56de\u503c\u603b\u662f\uff10\u548c\uff11\uff0c\u82e5\u8fd4\u56de\uff10\uff0c\u8868\u793a\u5220\u9664\u7684\u5143\u7d20\u4e0d\u5728set\u4e2d,\u5982<\/p> \n

\r\n int eraseReturn=numSet.erase(1);<\/pre> \n      <\/endl;>\n     <\/int>\n    <\/int>\n   <\/set>\n  <\/iostream><\/pre>\n<\/div>","orderid":"0","title":"C++\u4e2dset\u7684\u589e\u5220\u67e5\u904d\u5386\u5b9e\u73b0\u6559\u7a0b","smalltitle":"","mid":"0","fname":"c++\u7f16\u7a0b\u57fa\u7840","special_id":"0","bak_id":"0","info":"0","hits":"388","pages":"1","comments":"0","posttime":"2017-10-21 06:06:51","list":"1508537211","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"https:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"set<\/A> \u589e\u5220<\/A> \u67e5\u904d\u5386<\/A> \u5b9e\u73b0<\/A> \u6559\u7a0b<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"113.108.110.181","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"C++\u4e2dset\u7684\u589e\u5220\u67e5\u904d\u5386\u5b9e\u73b0\u6559\u7a0b","lastview":"1702554699","digg_num":"8","digg_time":"1714005226","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}