blob: a96bd6f2c5d9059378e16e677cda5c32e6255f62 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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;
}
|