count
#include <algorithm>
#include <iostream>
#include <vector>
using std::vector,
std::cerr;
class Temp{
public:
int a, b;
Temp(int i, int j):a(i), b(j){}
};
bool operator==(const Temp& l, const Temp& r)
{
return l.a == r.a && l.b == r.b;
}
typedef vector<Temp> my_vector;
int main(){
my_vector a = {Temp(0, 0), Temp(1, 1), Temp(2, 4), Temp(3, 9), Temp(4, 16), Temp(3, 9), Temp(5, 25), Temp(6, 36), Temp(3, 9), Temp(7, 49), Temp(8, 64), Temp(9, 81), Temp(10, 100), Temp(11, 121), Temp(12, 144), Temp(13, 169), Temp(14, 196), Temp(15, 225), Temp(16, 256), Temp(17, 289), Temp(18, 324), Temp(19, 361)};
int c = count(a.begin(), a.end(), Temp(3, 9));
cerr << "count: " << c << "\n";
return 0;
}
back
C++ Examples© 2024 TBD