/*#include "stdafx.h"*/
#include "vector"
#include "string"
#include "algorithm"
#include "functional"
#include "iostream"
using namespace std;
#define STANDARHEIGHT 165
#define STUDENTNUM 5
class 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;
}
countif
最新推荐文章于 2023-08-01 16:25:11 发布