#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
// Structure to represent a team
struct Team {
string players[3]; // Names of players
int totalRuns; // Total runs scored by the team
};
// Function to simulate a random score between 0 to 6 for each ball
int bowlDelivery() {
return rand() % 7; // Random score between 0 and 6
// Function to play an inning for a team
int playInning(string teamName, Team &team, Team &opposingTeam) {
int runs = 0;
int balls = 6;
cout << teamName << " is batting..." << endl;
// Randomly select a batsman and bowler
string batsman = [Link][rand() % 3];
string bowler = [Link][rand() % 3];
cout << "Batsman: " << batsman << " | Bowler: " << bowler << endl;
// Play 6 balls (one over)
for (int i = 0; i < balls; i++) {
int score = bowlDelivery(); // Random score for the ball
cout << "Ball " << (i + 1) << ": " << score << " runs" << endl;
runs += score;
cout << teamName << " scored " << runs << " runs in this inning." << endl;
return runs;
int main() {
srand(time(0)); // Seed for random number generation
// Define players for each team
Team TeamA = {{"PlayerA1", "PlayerA2", "PlayerA3"}, 0};
Team TeamB = {{"PlayerB1", "PlayerB2", "PlayerB3"}, 0};
// TeamA bats first
cout << "Inning 1: TeamA bats" << endl;
[Link] = playInning("TeamA", TeamA, TeamB);
// TeamB bats second
cout << "\nInning 2: TeamB bats" << endl;
[Link] = playInning("TeamB", TeamB, TeamA);
// Compare the scores to decide the winner
cout << "\nMatch Over!" << endl;
cout << "TeamA scored " << [Link] << " runs." << endl;
cout << "TeamB scored " << [Link] << " runs." << endl;
if ([Link] > [Link]) {
cout << "TeamA wins!" << endl;
} else if ([Link] > [Link]) {
cout << "TeamB wins!" << endl;
} else {
cout << "It's a tie!" << endl;
return 0;