summaryrefslogtreecommitdiff
path: root/gradeclustering-example.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gradeclustering-example.cpp')
-rw-r--r--gradeclustering-example.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/gradeclustering-example.cpp b/gradeclustering-example.cpp
new file mode 100644
index 0000000..cfa2bdd
--- /dev/null
+++ b/gradeclustering-example.cpp
@@ -0,0 +1,35 @@
+#include <iostream>
+#include <vector>
+#include "sales_data.hpp"
+#include "sales_item.hpp"
+
+/*
+ *
+ * original example from book, added printing out the vector
+ *
+ *
+ */
+
+using std::string;
+using std::cout;
+using std::cin;
+using std::cerr;
+using std::clog;
+using std::endl;
+using std::vector;
+int main () {
+
+ vector<unsigned> scores(11, 0);
+ unsigned grade;
+ while (cin >> grade) {
+ if (grade <= 100)
+ ++scores[grade/10];
+ }
+
+ for(auto i : scores) {
+ cout << i << " ";
+ }
+
+ cout << endl;
+ return 0;
+}