Q:

Once we’ve computed the cluster index, we can use it to subscript our vector and fetch the counter we want to increment

0

Once we’ve computed the cluster index, we can use it to subscript our vector and fetch the counter we want to increment.

All Answers

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

// count the number of grades by clusters of ten: 0--9, 10--19, . .. 90--99, 100
vector<unsigned> scores(11, 0); // 11 buckets, all initially 0
unsigned grade;
while (cin >> grade) { // read the grades
if (grade <= 100) // handle only valid grades
++scores[grade/10]; // increment the counter for the current cluster
}

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