#include <iostream>
#include <vector>
using namespace std;
template<typename T>
int count(vector<T> v1, T val){
int n = 0;
for(auto i = v1.begin(); i != v1.end(); i++)
if(val == *i) n++;
return n;
}
int main(){
vector<int> v1;
v1.push_back(3);
v1.push_back(3);
v1.push_back(3);
v1.push_back(1);
v1.push_back(-1);
v1.push_back(1);
cout<<1<<" occurs "<<count<int>(v1, 1)<<" times";
return 0;
}
Comments
Leave a comment