另外加上平均分數計算- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- //利用二維陣列, 試做一個包含五位同學, 各三組分數的成績表格.
-
- //國英數
- int Score [5][3] ={{100,10,40},{47,53,87},{98,34,88},{100,58,36},{47,58,30}};
- int Total =0;
- for(int i=0;i<5;i++)
- {
- cout <<"第"<<i+1<<"位同學的國,英,數 成績為:";
- for(int j=0;j<3;j++)
- {
- Total = Total+ Score[i][j];
- cout << Score[i][j] <<" ";
- }
-
- cout << "總分為:" << Total << "平均:" <<Total/3 <<endl;
- Total =0;
- }
-
-
- system("pause");
- return 0;
- }
複製代碼 |