本帖最後由 tonyh 於 2015-3-7 11:10 編輯
新增平均欄位.
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- string name[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
- float score[5][4]={{80,87,68,0},{70,89,88,0},{67,66,50,0},{45,43,68,0},{77,55,79,0}};
- cout<<"座號\t姓名\t\t國文\t英文\t數學\t平均"<<endl;
- cout<<"========================================================="<<endl;
- for(int i=0; i<5; i++)
- {
- cout<<i+1<<"\t"<<name[i]<<"\t\t";
- score[i][3]=(score[i][0]+score[i][1]+score[i][2])/3;
- for(int j=0; j<4; j++)
- {
- cout<<score[i][j]<<"\t";
- }
- cout<<endl;
- }
- system("pause");
- return 0;
- }
複製代碼 |