Hey guys!

Trying to write a standings program.

Everything has been getting along until I get to the point where two teams will have the same result (and it eventually goes into OT / shootout and so on).

What happens is it should be assigning point to both the teams and then go on to assign a second point to whoever won. But instead it's skipping the entire last loop and goes back to the beginning of the first if statement.


Also I'm aware that my code is pretty messy, I'm not sure if I'm actually qualified to know of any better solutions at this point but if anyone has any idea on how to shorten the linework do please recommend me.

On a side note: I'm aware that the four int values ("lag_a_res") and so on are not being used and I'm removing them.





So just to clarify if anything is not clearly understood. The program reads in if either of the team won. That works. But when the two teams have the same result, it skips the last loop and starts over.



Thank you in advance!


Code:

#include <iostream>
#include <string>
using namespace std;

string lag_a;
string lag_b;
string lag_c;
string lag_d;

int lag_a_val;
int lag_b_val;
int lag_c_val;
int lag_d_val;

int lag_a_res;
int lag_b_res;
int lag_c_res;
int lag_d_res;

void board();
void game();


int main ()

{




    cout << "Enter first team: \n";
    getline(cin, lag_a);
    cout << "Enter second team: \n";
    getline(cin, lag_b);
    cout << "Enter third team: \n";
    getline(cin, lag_c);
    cout << "Enter fourth team: \n";
    getline(cin, lag_d);

    cout << "\n \n \n";
    cout << "1. " << lag_a << endl;
    cout << "2. " << lag_b << endl;
    cout << "3. " << lag_c << endl;
    cout << "4. " << lag_d << endl;

    do
    {
        game ();
    }while (lag_a_val, lag_b_val, lag_c_val, lag_d_val < 7);



}


void board ()
{
    cout << "\n \n \n";
    cout << "1. " << lag_a << " " << lag_a_val << endl;
    cout << "2. " << lag_b << " " << lag_b_val << endl;
    cout << "3. " << lag_c << " " << lag_c_val << endl;
    cout << "4. " << lag_d << " " << lag_d_val << endl;

}

void game ()

{
    string otwinner;
    string awayteam;
    string hometeam;

    cout << "\n \n \n";
    cout << "Enter away team: \n";
    getline(cin, awayteam);
    cout << "Enter home team \n";
    getline(cin, hometeam);

    int awayres;
    int homeres;
    cout << "\n \n \n";
    cout << "Enter away team score: ";
    cin >> awayres;
    cout << "Enter home team score: ";
    cin >> homeres;
    cin.get();

if (awayres > homeres)
    {
        if (awayteam == lag_a)
        {
            lag_a_val += 2;

        }
        if (awayteam == lag_b)
        {
            lag_b_val += 2;

        }
        if (awayteam == lag_c)
        {
            lag_c_val += 2;

        }
        if (awayteam == lag_d)
        {
            lag_d_val += 2;

        }
    }
if (homeres > awayres)
    {
        if (hometeam == lag_a)
        {
            lag_a_val += 2;

        }
        if (hometeam == lag_b)
        {
            lag_b_val += 2;

        }
        if (hometeam == lag_c)
        {
            lag_c_val += 2;

        }
        if (hometeam == lag_d)
        {
            lag_d_val += 2;

        }
    }

if (homeres == awayres)
{
    if (hometeam == lag_a && awayteam == lag_b)
    {
        lag_a_val += 1;
        lag_b_val += 1;

        cout << "Who won in OT/Shootout? \n";
        cin >> otwinner;
    if (otwinner == lag_a)
    {
        lag_a_val += 1;
    }
        if (otwinner == lag_b)
    {
        lag_b_val += 1;
    }
    }


}

    board ();
}