diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Bachelor/Prog1/probeklausur/main.cpp | |
| download | Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.gz Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.bz2 | |
Diffstat (limited to 'Bachelor/Prog1/probeklausur/main.cpp')
| -rw-r--r-- | Bachelor/Prog1/probeklausur/main.cpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/Bachelor/Prog1/probeklausur/main.cpp b/Bachelor/Prog1/probeklausur/main.cpp new file mode 100644 index 0000000..a96bd6f --- /dev/null +++ b/Bachelor/Prog1/probeklausur/main.cpp @@ -0,0 +1,67 @@ +// Sven Eisenhauer
+// Probeklausur 09.02.2005
+//
+// Application to test class LottoGenerator
+
+#include "lotto.h"
+#include <iostream>
+using std::cout;
+using std::endl;
+#include<iomanip>
+using std::setw;
+
+int average(int *);
+
+const int ARRAY_SIZE=6;
+
+int main()
+{
+ LottoGenerator lotto;
+ int nrEinstZusatzZ=0;
+ long ZusatzZ;
+ int erg[ARRAY_SIZE];
+ const int NUMBERS=49;
+ int result[NUMBERS]={0};
+ int avg=0;
+
+ for(int i=0;i<10;i++)
+ {
+ lotto.drawAllNumbers();
+ lotto.sortSixNumbers();
+ lotto.printAllNumbers();
+ }
+
+ for(i=0;i<1000000;i++)
+ {
+ lotto.drawAllNumbers();
+ ZusatzZ=lotto.getAllNumbers(erg);
+ if(ZusatzZ<10)
+ nrEinstZusatzZ++;
+ }
+ cout << endl << "Eine einstellige Zusatzzahl gab es "<< nrEinstZusatzZ <<" mal.";
+
+ for(i=0;i<1000000;i++)
+ {
+ lotto.drawAllNumbers();
+ lotto.getAllNumbers(erg);
+ avg=average(erg);
+ result[avg]++;
+ }
+
+ cout << endl <<"Häufigkeitsverteilung: " << endl;
+ for (i=0;i<NUMBERS;i++)
+ cout << setw(3) << i+1 << setw(8) << result[i] << endl;
+
+ return 0;
+}
+
+int average(int* array)
+{
+ int sum=0;
+ int avg=0;
+
+ for (int i=0;i<ARRAY_SIZE;i++)
+ sum+=array[i];
+ avg=sum/ARRAY_SIZE;
+ return avg;
+}
|
