-
大小: 1.93KB文件類型: .zip金幣: 1下載: 0 次發布日期: 2021-02-21
- 語言: C/C++
- 標簽:
資源簡介
C++實戰源碼-通過指定的字符在集合中查找元素(入門級實例228).zip
代碼片段和文件信息
#include?
#include?
using?namespace?std;
void?main()
{
set?cSet; //利用set對象創建字符類型的集合
cSet.insert(‘B‘); //插入元素
cSet.insert(‘C‘);
cSet.insert(‘D‘);
cSet.insert(‘A‘);
cSet.insert(‘F‘);
cout?<“old?set:“?< set::iterator?it; //循環顯示集合中的元素
for(it=cSet.begin();it!=cSet.end();it++)
cout?<*it?< char?cTmp;
cTmp=‘D‘;
it=cSet.find(cTmp); //在集合中查找指定的元素
cout?<“start?find:“?< if(it==cSet.end()) //沒找到元素
cout?<“not?found“?< else //找到元素
cout?<“found“?< cTmp=‘G‘;
it=cSet.find(cTmp); //查找指定的元素
cout?<“start?find:“?< if(it==cSet.end()) //沒找到元素
cout?<“not?found“?< else //找到元素
cout?<“found“??<}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????821??2010-03-09?13:10??Sample\main.cpp
?????文件????????4276??2010-02-03?20:57??Sample\Sample.dsp
?????文件?????????535??2009-12-21?17:11??Sample\Sample.dsw
- 上一篇:C++實戰源碼-利用數組計算平均成績
- 下一篇:C++實戰源碼-二維數組每行的最大值
評論
共有 條評論