Q:

Repeat the previous program, but read values into a list of strings

0

 Repeat the previous program, but read values into a list of strings.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <algorithm>
#include <iostream>
#include <list>
#include <string>

int main() {
  std::string val;
  std::cin >> val;
  std::list<std::string> vi;
  for (std::string i; std::cin >> i; vi.push_back(i)) {}
  std::cout << "Value "" << val << "" occours "
            << std::count(vi.begin(), vi.end(), val) << " time(s) in sequence."
            << std::endl;

  // The only changes we made are the type of the variables, the function call
  // is still the same with ex10.1.

  return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now