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 45 46
|
#include <iostream>
using namespace std;
int main()
{
constexpr int MAXROW{ 5 }, MAXCOL{ 4 };
int ar[MAXROW][MAXCOL] =
{
{ 80, 77, 69, 0 },
{ 100, 95, 90, 0 },
{ 60, 54, 72, 0 },
{ 42, 80, 67, 0 },
{ 82, 90, 87, 0 }
};
for (int row = 0; row < MAXROW; row++)
{
for (int col = 0; col < 4; col++)
{
cout << ar[row][col] << "\t";
}
cout << '\n';
}
for (int row = 0; row < MAXROW; row++)
{
for (int col = 0; col < MAXCOL - 1; col++)
{
// <--- What would you do here to sum the 3 scores?
// <--- Then could you do this in the 1st for loop?
}
cout << '\n';
}
// A fair C++ replacement for "system("pause")". Or a way to pause the program.
// The next line may not be needed. If you have to press enter to see the prompt it is not needed.
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; // <--- Not required, but makes a good break point.
}
|