Q:

Rewrite the grade clustering program from § 3.3.3 (p. 104) using iterators instead of subscripts

0

Rewrite the grade clustering program from § 3.3.3 (p. 104) using iterators instead of subscripts.

All Answers

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

#include <iostream>
#include <vector>

int main() {
  std::vector<unsigned> scores(11, 0);
  unsigned grade;
  while (std::cin >> grade)
    ++*(scores.begin() + grade / 10);
  for (const auto & elem : scores)
    std::cout << elem << ' ';
  std::cout << std::endl;

  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