#include <cstddef>
#include <vector>
#include <iostream>
using namespace std;
template <typename iterator, typename type>
size_t count(iterator data_start, iterator data_end, const type &value) {
size_t counter=0;
for (iterator scan=data_start; scan!=data_end; ++scan)
if (*scan==value) counter++;
return(counter);
}
template <typename iterator>
void print_all(iterator data_start, iterator data_end) {
for (iterator scan=data_start; scan!=data_end; ++scan)
cout << ' ' << *scan;
cout << endl;
}
int main() {
vector<double> V;
cout << "Please enter several values followed by the letter 's':" << endl;
for (;;) {
double x;
cin >> x;
if (cin.fail()) break;
V.push_back(x);
}
cin.clear();
cin.ignore(256,'\n');
cout << "What value would you like to count? " << endl;
double val;
cin >> val;
size_t c= count(V.begin(), V.end(), val);
cout << c << " items found." << endl;
cout << "The data collection consisted of:" << endl;
print_all(V.begin(), V.end());
return(0);
}