Skip to content

Instantly share code, notes, and snippets.

@krysseltillada
Created May 20, 2015 15:04
Show Gist options
  • Save krysseltillada/5fd3315e977a2f92b3c2 to your computer and use it in GitHub Desktop.
Save krysseltillada/5fd3315e977a2f92b3c2 to your computer and use it in GitHub Desktop.
grade clustering using iterators
#include <iostream>
#include <vector>
int main()
{
std::vector<unsigned> scores(11, 0);
unsigned grade = 0;
auto it = scores.begin();
for(;std::cin >> grade;) {
if (grade <= 100) {
*(it + (grade / 10)) += 1;
}
}
for(std::vector<unsigned>::iterator it2 = scores.begin(); it2 != scores.end(); ++it2)
std::cout << *it2 << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment