2D Arrays

What's wrong with my code????
Hi, I'm a new programmer, my professor gave me the following assignment:
Assume 3 teams and 5 games. Declare these as constants.

Ask the user to input the team name. Save in a 1D array.

For each game, ask the user to input the number of goals scored by that team. Save in a 2D array

Find the high goals for each team. Store in a 1D array.

Find game number with the high goal for each team. Store in a 1D array.


Display in a table format the following.

Team names as rows. Game numbers as columns.

List Team Name, Goals per game for each game, high goals and game number with high goals.


- I'm struggling with this right now, if anyone could help me out or point me in the right direction that would reaaaaaaaaaaally help.

thanks




#include<iostream>
#include <string>
#include <iomanip>

using namespace std;

int main()
{
const int TEAMS = 2;
const int GAMES = 3;

int numGames[GAMES];
int team[TEAMS];
int i, j;
int userInput = 0, totalGoals = 0;
int numGoals[TEAMS][GAMES];
string teamName;
int highScore[GAMES];

for (int i = 0; i < TEAMS, i++;)
{
cout << "Please enter team name: " << endl;
getline(cin, teamName[i]);

totalGoals = 0;

for (int j = 0; j < GAMES, j++;)
{
numGoals[j][i] = 0;
cout << "Game " << numGames << endl;
cout << "How many goals were scored by your team? " << endl;
cin >> numGoals[j][i];
if (numGoals[i][j] > highScore[i])
{
highScore[i] > numGoals[j][i];
}
}
cin.ignore();
cout << "Highest number of goals " << highScore[i] << " is for this season" << endl;

cout << setw(8) << "Team Name" << setw(8) << "Game 1" << setw(8) << "Game 2" << setw(8) << "Game 3" << setw(8) << "Game 4" << setw(8) << "Game 5 " << endl;

for (int i = 0; i < TEAMS, i++;)
{
cout << setw(8) << teamName[i];
for (int j = 0; j < GAMES; j++)
{
cout << setw(8) << numGoals[j][i];
}
for (int i = 0; i < TEAMS; i++)
{
cout << setw(8) << highScore[i];
}
cout << endl;
}

}
return 0;
}

Last edited on
Topic archived. No new replies allowed.