This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
90 lines (75 loc) · 2.62 KB
/
Copy pathmain.cpp
File metadata and controls
90 lines (75 loc) · 2.62 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <iostream>
#include "Team.h"
#include "Competitor.h"
#include <time.h>
#include <cstdlib>
using namespace std;
void Match (Team team1, Team team2);
int main()
{
cout << "Welcome to the match of Dolnoslaskie Mecze Matematyczne!" << endl << endl;
srand(time(NULL));
Team team0;
Team team1;
Match (team0, team1);
return 0;
}
void Match (Team team1, Team team2)
{
Team teams[2]={team1, team2};
bool exReturn[2], ifSolved[10];
for (int i=0; i<10; i++)
ifSolved[i]=false;
exReturn[0]=false;
exReturn[1]=false;
int point[2];
point[0]=0;
point[1]=0;
teams[0].Solving();
teams[1].Solving();
for (int i=0; i<8; i++)
{
cout << "EX NR " << i << endl;
int random = rand()%10;
while (ifSolved[random]==true)
random = rand()%10;
ifSolved[random]=true;
bool teamAsk;
if (i%2==0)
teamAsk=false;
else
teamAsk=true;
cout << "Team nr " << teamAsk << " is asking a task nr " << random << endl;
if (exReturn[!teamAsk]==false)
{
int random1 = rand()%2;
if (random1==1)
{
exReturn[!teamAsk]=true;
cout << "Team nr " << !teamAsk << " is returning a task nr " << random << endl;
cout << "Team nr " << teamAsk << " is solving a task nr " << random << endl;
cout << "Team nr " << teamAsk << " scored " << 2*teams[teamAsk].points[random]-10 << endl;
point[teamAsk]+=2*teams[teamAsk].points[random]-10;
}
else
{
cout << "Team nr " << !teamAsk << " is solving a task nr " << random << endl;
cout << "Team nr " << !teamAsk << " scored " << teams[!teamAsk].points[random] << endl;
point[!teamAsk]+=teams[!teamAsk].points[random];
}
}
else
{
cout << "Team nr " << !teamAsk << " is solving a task nr " << random << endl;
cout << "Team nr " << !teamAsk << " scored " << teams[!teamAsk].points[random] << endl;
point[!teamAsk]+=teams[!teamAsk].points[random];
}
cout << "points: " << point[0] << " " << point[1] << endl << endl;
}
if (point[0]>point[1])
cout << "The winner is team nr 0! Congratulations!" << endl << endl;
if (point[0]<point[1])
cout << "The winner is team nr 1! Congratulations!" << endl << endl;
if (point[0]==point[1])
cout << "The teams drew!" << endl << endl;
}