// twodarray.cxx - Two-dimensional array example
// This program tallies homework scores for students
//

#include <iostream>
#include <iomanip>

using namespace std;

const int STUDENTS=5;
const int HW=4;

int main()
{
  int grades[STUDENTS][HW];     // the students' grades 
  int total[STUDENTS];          // the total grade for each student

  for (int i=0; i<STUDENTS; i++)
    {
      total[i] = 0;                 // set each student's total to 0

      for (int j=0; j<HW; j++)
        {
          cin >> grades[i][j];      // read a grade for student i...
          total[i] += grades[i][j]; // ...and add it in to the student's total
        }

    }

  for (int j=0; j<HW; j++)              // for each homework...
    {
      cout << endl;
      for (int i=0; i<STUDENTS; i++)    // ...print out each student's grade
	cout << setw(4) <<grades[i][j]; //    for that homework
    }

  cout << endl << "-----------------------------------------------" << endl;

  for (int i=0; i<STUDENTS; i++)
    cout << setw(4) << total[i];   // print total for each student
  cout << endl;
}



