1

DispatchAccountSport

by The Federal Republic of Wizlandia. . 25 reads.

Match Results Generator (Football)

Instructions: Copy and paste the code below into https://www.onlinegdb.com/. Language is C++.

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <math.h>
#include <time.h>

int main()
{
srand(time(NULL));
std::string homeName;
std::string awayName;
double homeStrength;
double awayStrength;
std::cout << "Enter Home Team: ";
std::cin >> homeName;
std::cout << "Enter Home Team Strength out of 5: ";
std::cin >> homeStrength;
std::cout << "Enter Away Team: ";
std::cin >> awayName;
std::cout << "Enter Away Team Strength out of 5: ";
std::cin >> awayStrength;
double homeMod = 100*sqrt(homeStrength)*0.02/7.5;
double awayMod = 100*sqrt(awayStrength)*0.02/7.5;
double homeScore = 0;
double awayScore = 0;
std::cout << "\nFirst Half\n";
for (int i = 1; i < 51; i++)
{
if (rand()%100 < homeMod)
{
homeScore = homeScore + 1;
std::cout << homeName << ": " << i << "'\n";
}
if (rand()%100 < awayMod)
{
awayScore = awayScore + 1;
std::cout << awayName << ": " << i << "'\n";
}
}
std::cout << "\nSecond Half\n";
for (int i = 46; i < 101; i++)
{
if (rand()%100 < homeMod)
{
homeScore = homeScore + 1;
std::cout << homeName << ": " << i << "'\n";
}
if (rand()%100 < awayMod)
{
awayScore = awayScore + 1;
std::cout << awayName << ": " << i << "'\n";
}
}
std::cout << "\nFull Time\n" << homeScore << ":" << awayScore << "\n";
return 0;
}

The Federal Republic of Wizlandia

Edited:

RawReport