1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#include <iostream>
int main(int argc, const char * argv[])
{
// insert code here...
std::cout << "\nTop NBA Player Points Scored in Last 5 Games\n" << std::endl; // <--- Changed. Added '\n's.
const int rows = 5;
const int columns = 5;
int total = 0;
double average = 0.0;
int Points[5][5] =
{
{ 54, 57, 57, 44, 40 },
{ 31, 28, 23, 28, 21 },
{ 15, 16, 40, 37, 40 },
{ 27, 16, 26, 23, 36 },
{ 24, 20, 40, 26, 12 }
};
for (int r = 0; r < rows; ++r)
{
std::cout << "Player " << r + 1 << ": ";
for (int c = 0; c < columns; ++c)
{
std::cout << Points[r][c] << " ";
total += Points[r][c];
}
average = total / columns;
std::cout << "Average: " << average << std::endl;
total = 0;
average = 0.0;
}
// This next line may or may not be needed. If you have to press "Enter" to see the ptompt you do not
// need this next line.
//std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // <--- Requires header file <limits>.
std::cout << "\n\n Press Enter to continue";
std::cin.get();
return 0;
}
|