Website Summary Files Commits Branches @commit @diff @stats
path: root / Week02 / Exercise03 / main.cpp
diff options
context:
space:
mode:
1 files changed, 17 insertions, 0 deletions
-rw-r--r--Week02/Exercise03/main.cpp17
diff --git a/Week02/Exercise03/main.cpp b/Week02/Exercise03/main.cpp
new file mode 100644
index 0000000..07f59fb
--- /dev/null
+++ b/Week02/Exercise03/main.cpp
@@ -0,0 +1,17 @@
+#include <iostream>
+#include "intarray.h"
+
+int main() {
+ unsigned N;
+ std::cin >> N;
+
+ IntArray ia = newIntArray(N);
+ for (unsigned i = 0; i < ia.size; ++i)
+ std::cin >> ia.elems[i];
+
+ std::cout << ((double)ia.sum() / ia.size) << std::endl;
+
+ deleteIntArray(ia);
+
+ return 0;
+}