diff --git a/CppTutorial.cbp b/CppTutorial.cbp
index 2f568c5..cbf7bda 100644
--- a/CppTutorial.cbp
+++ b/CppTutorial.cbp
@@ -33,6 +33,8 @@
+
+
diff --git a/main.cpp b/main.cpp
index b7c4cc1..122d7dc 100644
--- a/main.cpp
+++ b/main.cpp
@@ -47,3 +47,4 @@ string prompts(const string &message, bool *success) {
*success = true;
return tr;
}
+
diff --git a/stats.cpp b/stats.cpp
new file mode 100644
index 0000000..b526eb3
--- /dev/null
+++ b/stats.cpp
@@ -0,0 +1,21 @@
+#include "stats.h"
+#include
+#include
+
+double med(std::vector &scores,bool ignoreExtremes) {
+ const auto len = scores.size() - (ignoreExtremes && scores.size() > 2) ? 2 : 0;
+ sort(scores.begin(), scores.end());
+ using vec_size = std::vector::size_type;
+ const vec_size middle = (vec_size) (len / 2);
+ if (middle%2 == 1)
+ return scores[middle];
+ else
+ return (scores[middle - 1] + scores[middle]) / 2.0;
+}
+
+double avg(const std::vector &scores,bool ignoreExtremes) {
+ auto sum = 0.0;
+ using vec_size = std::vector::size_type;
+ for (vec_size i = (ignoreExtremes && scores.size() > 2) ? 1 : 0; i < scores.size() - (ignoreExtremes && scores.size() > 2) ? 1 : 0; i++) sum += scores[i];
+ return sum / static_cast(scores.size() - (ignoreExtremes && scores.size() > 2) ? 2 : 0);
+}
diff --git a/stats.h b/stats.h
new file mode 100644
index 0000000..dcc76e9
--- /dev/null
+++ b/stats.h
@@ -0,0 +1,9 @@
+#ifndef STATS_H_INCLUDED
+#define STATS_H_INCLUDED
+
+#include
+
+double med(std::vector &scores,bool ignoreExtremes);
+double avg(const std::vector &scores,bool ignoreExtremes);
+
+#endif // STATS_H_INCLUDED