Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

655248 hw #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions 655248.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <iostream>
using namespace std;
int main() {
int people;
float score[1000][5] = {0};
float avgPersonal[10] = {0};
float buffer = 0;
float avgSubject[10] = {0};


cout << "請依序輸入國英數自社";
cin >> people;
for (int i = 0; i < people; i++){
cin >> score[i][0];
cin >> score[i][1];
cin >> score[i][2];
cin >> score[i][3];
cin >> score[i][4];
}
for (int j = 0; j < people; j++){
for(int k = 0; k < 5; k++){
buffer = score[j][k] + buffer;
avgPersonal[j] = buffer;

}
cout << avgPersonal[j]/5 << "\n";
buffer = 0;
}
buffer = 0;
for(int l = 0; l < 5; l++){
for(int m = 0; m < people; m++){
buffer = score[m][l] + buffer;
avgSubject[l] = buffer;
}
buffer = 0;
cout << avgSubject[l]/people << "\n";
}

}