count

来源:互联网 发布:我的淘宝网登陆 编辑:程序博客网 时间:2024/04/20 06:23
 
// count.cpp -- 2011-10-02-22.00#include "stdafx.h"#include <iostream>#include <algorithm>#include <vector>using std ::vector ;int _tmain(int argc, _TCHAR* argv[]){int arr1[] = {1, 2, 3, 4, 5, 7, 8, 9} ;vector<int> vec1(arr1, arr1 + sizeof arr1 / sizeof (int)) ;//count (beg, end, val) ;//操作前:[beg,end)标示输入序列.val是要查找的值.//操作后:确定输入序列中值为val的元素的出现次数.//返回值:返回该值出现的次数.//备注:无.size_t iCount = count(vec1.begin(), vec1.end(), 3) ;std ::cout << iCount << std ::endl ;std ::cin.get() ;return 0 ;}
原创粉丝点击