11-03-02-3.cpp

来自「more efftive 代码」· C++ 代码 · 共 25 行

CPP
25
字号
#include <iostream>#include <vector>#include <algorithm>#include <functional>using namespace std;int main(){  typedef pair<int, char*> Pair;    vector<Pair> V;  V.push_back(Pair(3, "A"));  V.push_back(Pair(7, "B"));  V.push_back(Pair(2, "C"));  V.push_back(Pair(3, "D"));  V.push_back(Pair(0, "E"));  V.push_back(Pair(6, "E"));    cout << "Number of elements with key equal to 3: "       << count_if(V.begin(), V.end(),                   compose1(bind2nd(equal_to<int>(), 3),                            select1st<Pair>()))       << endl;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?