返回列表 發帖

[隨堂測驗] 陣列 (八) - 成績表 2

本帖最後由 葉桔良 於 2022-7-2 16:04 編輯

新宣告一個一維陣列,以用來插入姓名欄位,如下圖所示。

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string name[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
  7.     int score[5][3]={{43,55,77},{76,77,43},{78,11,22},{43,89,88},{98,44,67}};
  8.     cout<<"座號\t姓名\t\t國文\t英文\t數學"<<endl;
  9.     cout<<"============================================"<<endl;
  10.     for(int i=0; i<5; i++)
  11.     {
  12.          cout<<i+1<<"\t"<<name[i]<<"\t\t";
  13.          for(int j=0; j<3; j++)
  14.               cout<<score[i][j]<<"\t";
  15.          cout<<endl;
  16.     }
  17.     system("pause");
  18.     return 0;
  19. }
複製代碼

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

此帖僅作者可見

TOP

返回列表