#include <iostream>
#include <vector>
#include <random>
using namespace std;

int randomInt() { return rand(); }

struct person
{
    int athletic;
    int smarts;
    int spirit;
    int contestVal;
};

int AthleticContest(vector<person> &subjects)
{
     cout << "Athletic Contest!!!" << endl << endl;
     for (int hh = 0; hh < subjects.size(); hh++)
     {
         int result = subjects[hh].athletic;
         subjects[hh].contestVal = result;
         cout << "Contestant # " << (hh+1) << ") " << subjects[hh].contestVal  << endl;
     }
     int winner;
     int tempWin = -1;
     for (int hh = 0; hh < subjects.size(); hh++)
     {
        if (subjects[hh].contestVal > tempWin)
        {
            tempWin = subjects[hh].contestVal;
            winner = hh;
        }
        else if (subjects[hh].contestVal == tempWin)
        {
            if (randomInt() > 4)
                winner = hh;
        }
    }
    cout << "Winner is Contestant # " << (winner+1)   << endl;

    return winner;
}

int main()
{
    vector<person> subject(2);  // create only 2 items

    subject[0].athletic = 5;
    subject[0].smarts   = 3;
    subject[0].spirit   = 1;
    subject[1].athletic = 1;
    subject[1].smarts   = 3;
    subject[0].spirit   = 5;
    subject[1].athletic = 3;
    subject[1].smarts   = 5;
    subject[0].spirit   = 1;

    AthleticContest(subject);
    
    person hbolt = {4, 2, 1, 0}; 
    subject.emplace_back (hbolt);
    AthleticContest(subject);
    
}
