내가푼답
#include <iostream>
#include <iomanip>
using namespace std;
#define ROW 3
#define COL 5
void main()
{
int a[ROW][COL] = {0, };
int r, c, sum[COL] = { 0, }, sum2[COL] = { 0, };
float mean_row[ROW], sum3 = 0;
float mean_row2[COL] = { 0, }, mean_row3;
for(r= 0; r<ROW; r++){
a[r][0] =r+1;
cout<<"\n>> "<< a[r][0] <<" 번째 학생의 점수를 입력하세요\n";
for(c= 1; c <= COL-1; c++) {
cout<<c << "번째 과목 => " ;
cin>>a[r][c];
}
}
for(r= 0; r<ROW; r++){
for(c=1; c<=COL-1; c++) {
sum[r] += a[r][c];
}
mean_row[r]=(float)sum[r]/(COL-1);
}
for (r = 1; r < COL; r++) {
for (c = 0; c <= ROW - 1; c++) {
sum2[r-1] += a[c][r];
}
mean_row2[r-1] = (float)sum2[r-1] / ROW;
}
for (r = 0; r < ROW; r++) {
sum3 += mean_row[r];
}
mean_row3 = sum3 / ROW;
cout<<"\n\n\t\t\t 학 생 별 성 적 표";
cout<<"\n\t\t\t ===================\n";
cout<< "\n 번호 국어 영어 수학 사회 평 균";
// cout<<"\n\t"<<"---------------------------------------------------------------\n";
cout<<"\n\t"<<setfill('-')<<setw(63)<<"-"<<endl<<setfill(' ');
for(r= 0; r<ROW; r++){
for(c= 0; c<COL; c++) cout<<setw(11)<<a[r][c];
cout<<setw(15)<<mean_row[r]<<endl;
}
cout << "\t" << setfill('-') << setw(63) << "-" << endl << setfill(' ');
cout << setw(11) << "평균";
for (c = 0; c < COL-1; c++) cout << setw(11) << mean_row2[c];
cout << setw(11) << mean_row3;
cout<<endl<<endl;
}