countif

来源:互联网 发布:php文件上传下载系统 编辑:程序博客网 时间:2024/05/02 01:28
/*#include "stdafx.h"*/#include "vector"#include "string"#include "algorithm"#include "functional"#include "iostream"using namespace std;#define STANDARHEIGHT165#define STUDENTNUM5class CStudent{public:CStudent( int iHeight ) : m_iHeight( iHeight ){}int GetHeight() const{return m_iHeight;}private:int m_iHeight;};bool countHeight( int iHeight, const CStudent st){return st.GetHeight() > iHeight;}/*int _tmain(int argc, _TCHAR* argv[])*/int main(){vector<CStudent> vecStudent;for (int i = 0; i < STUDENTNUM; i++){vecStudent.push_back( CStudent( STANDARHEIGHT - 10 + i * 10 ) );}const int nStandarHeight = STANDARHEIGHT;int iCount = count_if( vecStudent.begin(), vecStudent.end(), bind1st( ptr_fun( countHeight ), nStandarHeight ) );cout << "the student height greater than Standar Number is : " << iCount << endl;return 0;}

0 0
原创粉丝点击