本帖最後由 陳品肇 於 2019-2-1 21:20 編輯
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- string name[5]={"王一美","王二美","王三美","王四美","王五美"};
- float score[5][4] ={{90,90,85,0} ,
- {70,75,85,0},
- {80,95,80,0},
- {70,95,75,0},
- {80,85,95,0}};
-
- cout<<"座號\t姓名\t\t國文\t英文\t數學\t平均"<<endl;
- cout<<"===================================================="<<endl;
- for(int i=0;i<5;i++)
- {
- cout<<i+1<<"\t"; // 印座號
- cout<< name[i]<<"\t\t"; //印姓名
- //[0][3]= ([0][0]+[0][1]+[0][2])/3
- 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;
- }
複製代碼 |