Super Bowl Simulation Code

void SimulateSuperBowl()
{
const int NUM_ITERATIONS = 1000000;
int times3TeamsWin15=0;
int timesAnyTeamWins5=0;
int timesAnyTeamWins6=0;
int timesAnyTeamWins7=0;
int timesAnyTeamWins8=0;

for (int pass=0;pass {
int aWins[32];
for (int i=0;i<32;i++)
aWins[i]=0;

for (int year=0;year<40;year++)
{
int baseYear = 1966+year;
int numTeams;

if (baseYear>=2002) //texans
numTeams = 32;
else if (baseYear>=1999) //browns
numTeams = 31;
else if (baseYear>=1995) //panthers and jags
numTeams = 30;
else if (baseYear>=1976) //seahawks and bucs
numTeams = 28;
else
numTeams=26; //original num of teams

int winner = (rand() % numTeams);
aWins[winner]++;
}

int highest1 = -1;
int highest2 = -1;
int highest3 = -1;
for (int i=0;i<32;i++)
{
if (highest1==-1)
highest1 = i;
else if (aWins[i]>aWins[highest1])
{
highest3=highest2;
highest2=highest1;
highest1 = i;
}
else if (highest2==-1)
highest2 = i;
else if (aWins[i]>aWins[highest2])
{
highest3=highest2;
highest2=i;
}
else if (highest3==-1)
highest3 = i;
else if (aWins[i]>aWins[highest3])
{
highest3=i;
}
if (aWins[i]>=5)
timesAnyTeamWins5++;
if (aWins[i]>=6)
timesAnyTeamWins6++;
if (aWins[i]>=7)
timesAnyTeamWins7++;
if (aWins[i]>=8)
timesAnyTeamWins8++;

}

int highestTotal = aWins[highest1] + aWins[highest2] + aWins[highest3];
if (highestTotal>=15)
times3TeamsWin15++;
}

String s;
s=”";
s < < "\nTimes 3 teams win 15 = " << FloatToString((((float)100 * times3TeamsWin15) / NUM_ITERATIONS), 3) << "%";
s << "\nTimes 1 teams wins 5 = " << FloatToString((((float)100 * timesAnyTeamWins5) / (32 * NUM_ITERATIONS)), 3) << "%";
s << "\nTimes 1 teams wins 6 = " << FloatToString((((float)100 * timesAnyTeamWins6) / (32 * NUM_ITERATIONS)), 3) << "%";
s << "\nTimes 1 teams wins 7 = " << FloatToString((((float)100 * timesAnyTeamWins7) / (32 * NUM_ITERATIONS)), 3) << "%";
s << "\nTimes 1 teams wins 8 = " << FloatToString((((float)100 * timesAnyTeamWins8) / (32 * NUM_ITERATIONS)), 3) << "%";
PL_OutputDebug(s);
}