#include<iostream>
using namespace std;
void printTable(int table[][3], int rows);
int main()
{
int scores[4][3];
// Input game scores:
for(int i=0; i<3; i++) // loop through 3 games
{
for(int j=0;j<4; j++) // loop through 4 players
{
cout << "Input score for player " << j+1
<< " and game " << i+1 << ": ";
cin >> scores[j][i];
}
}
// Output scores as table
printTable(scores, 4);
return 0;
}
// Pre-conditions: input two-dimensional array with
// three columns and multiple number
// of rows (number of rows specified
// by second input)
// Post-condition: print content of two-dimensional
// array to screen
void printTable(int scores[][3], int rows)
{
cout << "The scores are:\n";
for(int i=0; i<rows; i++) // Loop through players
{
cout << "Player " << i+1 << ": ";
for(int j=0; j<3; j++) // Loop through game results
{
cout << scores[i][j] << " ";
}
cout << endl;
}
}