#include #include #include using namespace std; const int COLUMNS = 3; /** Computes the total of a row in a table. @param table a table with 3 columns @param row the row that needs to be totaled @return the sum of all elements in the given row */ int main() { const int COUNTRIES = 7; const int MEDALS = 3; string countries[] = {"Canada", "China", "Japan","Russia", "Switzerland", "Ukraine", "United States" }; int counts[COUNTRIES][MEDALS] = { { 0, 0, 1 }, { 0, 1, 1 }, { 1, 0, 0 }, { 3, 0, 1 }, { 0, 1, 0 }, { 0, 0, 1 }, { 0, 2, 0 } }; cout << " Country Gold Silver Bronze Total" << endl; // Print countries, counts, and row totals for (int i = 0; i < COUNTRIES; i++) { cout << setw(15) << countries[i]; // Process the ith row for (int j = 0; j < MEDALS; j++) cout << setw(8) << counts[i][j]; int total = 0; for (int j = 0; j < COLUMNS; j++) total = total + counts[i][j]; cout << setw(8) << total << endl; } system("pause"); return 0; }