-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfootball
More file actions
44 lines (36 loc) · 1.21 KB
/
football
File metadata and controls
44 lines (36 loc) · 1.21 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
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
// Function to predict goal scoring probability
int predictGoalScorer() {
// Seed the random number generator
srand(time(0));
// Generate a random number between 1 and 100
int randomNumber = rand() % 100 + 1;
// Define thresholds for different goal scorers
int player1Threshold = 30; // Adjust these values based on player statistics
int player2Threshold = 50;
int player3Threshold = 70;
// Predict the goal scorer based on the random number
if (randomNumber <= player1Threshold) {
return 1; // Player 1 scores
} else if (randomNumber <= player2Threshold) {
return 2; // Player 2 scores
} else if (randomNumber <= player3Threshold) {
return 3; // Player 3 scores
} else {
return 0; // No goal scored
}
}
int main() {
// Call the function to predict the goal scorer
int goalScorer = predictGoalScorer();
// Display the predicted goal scorer
if (goalScorer == 0) {
cout << "No goal scored in this match." << endl;
} else {
cout << "Goal scored by Player " << goalScorer << "!" << endl;
}
return 0;
}