Upload files to "ex1A_mean_values"

This commit is contained in:
Jakob Schratter 2025-10-22 15:16:25 +02:00
commit 6be81d2d73
3 changed files with 88 additions and 0 deletions

35
ex1A_mean_values/main.cpp Normal file
View file

@ -0,0 +1,35 @@
#include "means.h"
#include <vector>
#include <iostream>
using namespace std;
int main(int argc, char **argv)
{
double arithmetic_mean, geometric_mean, harmonic_mean;
// Fixed version
calculate_means(1, 4, 16, arithmetic_mean, geometric_mean, harmonic_mean);
cout << arithmetic_mean << ", " << geometric_mean << ", " << harmonic_mean << endl;
calculate_means(2, 3, 5, arithmetic_mean, geometric_mean, harmonic_mean);
cout << arithmetic_mean << ", " << geometric_mean << ", " << harmonic_mean << endl;
calculate_means(1000, 4000, 16000, arithmetic_mean, geometric_mean, harmonic_mean);
cout << arithmetic_mean << ", " << geometric_mean << ", " << harmonic_mean << endl;
cout << "--------------------------------" << endl;
// Scalable version
calculate_means(vector<int> {1, 4, 16}, arithmetic_mean, geometric_mean, harmonic_mean);
cout << arithmetic_mean << ", " << geometric_mean << ", " << harmonic_mean << endl;
calculate_means(vector<int> {2, 3, 5}, arithmetic_mean, geometric_mean, harmonic_mean);
cout << arithmetic_mean << ", " << geometric_mean << ", " << harmonic_mean << endl;
calculate_means(vector<int> {1000, 4000, 16000}, arithmetic_mean, geometric_mean, harmonic_mean);
cout << arithmetic_mean << ", " << geometric_mean << ", " << harmonic_mean << endl;
return 0;
}