zoukankan      html  css  js  c++  java
  • 65.算法容器函数

     1 #include <iostream>
     2 #include <functional>
     3 #include <vector>
     4 #include <algorithm>
     5 #include <numeric>
     6 using namespace std;
     7 using namespace std::placeholders;
     8 
     9 class myclass
    10 {
    11 public:
    12     int get(int data)
    13     {
    14         return data % 2;
    15     }
    16 };
    17 
    18 void main()
    19 {
    20     //创建容器
    21     vector<int> myint{ 1,2,3,4,5,6,7,8,9,10 };
    22     //逐个数据进行判断是否满足lambda表达式
    23     int num = count_if(myint.begin(), myint.end(), [](int data)->bool {return data % 2 == 0; });
    24     cout << num << endl;
    25     myclass my1;
    26     auto fun = bind(&myclass::get, &my1, _1);
    27     num = count_if(myint.begin(), myint.end(), [](int data)->bool {return data % 2 == 0; });
    28     cout << num << endl;
    29     cin.get();
    30 }
  • 相关阅读:
    新浪微博采用Oauth发送图片和文字
    android proguard也有弱点
    POJ 2376
    POJ 3259
    POJ 2253
    POJ 1062
    POJ 2299
    POJ 2186
    POJ 1860
    POJ 2823
  • 原文地址:https://www.cnblogs.com/xiaochi/p/8568424.html
Copyright © 2011-2022 走看看