Board logo

標題: 陣列 (五) - 成績表 (一) [打印本頁]

作者: 陳品肇    時間: 2018-9-7 16:11     標題: 陣列 (五) - 成績表 (一)

利用二維陣列, 試做一個包含五位同學, 各三組分數的成績表格.
表格的形式如下:
[attach]4744[/attach]
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int score[5][3]={{90,85,85},{70,75,80},{80,95,80},{70,95,75},{80,85,95}};
  7.     cout<<"座號\t國文\t英文\t數學"<<endl;
  8.     cout<<"============================"<<endl;
  9.     for(int i=0; i<5; i++)
  10.     {
  11.        cout<<i+1<<"\t";
  12.        for(int j=0; j<3; j++)
  13.        {
  14.            cout<<score[i][j]<<"\t";
  15.        }
  16.        cout<<endl;     
  17.     }
  18.     system("pause");
  19.     return 0;   
  20. }
複製代碼

作者: 蔡季庭    時間: 2018-9-12 18:24

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int score[5][3]={{90,85,85},
  7.     {70,75,80},
  8.     {80,95,80},
  9.     {70,95,75},
  10.     {80,85,95}};
  11.     cout<<"座號\t國文\t英文\t數學"<<endl;
  12.     cout<<"============================"<<endl;
  13.     for(int i=0; i<5; i++)
  14.     {
  15.        cout<<i+1<<"\t";
  16.        for(int j=0; j<3; j++)
  17.        {
  18.            cout<<score[i][j]<<"\t";
  19.        }
  20.        cout<<endl;     
  21.     }
  22.     system("pause");
  23.     return 0;   
  24. }
複製代碼

作者: 蔡依宸    時間: 2018-9-12 18:26

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int score[5][3]={{90,85,85},{70,75,80},{80,95,80},{70,95,75},{80,85,95}};
  7.     cout<<"座號\t國文\t英文\t數學"<<endl;
  8.     cout<<"============================"<<endl;
  9.     for(int i=0; i<5; i++)
  10.     {
  11.        cout<<i+1<<"\t";
  12.        for(int j=0; j<3; j++)
  13.        {
  14.            cout<<score[i][j]<<"\t";
  15.        }
  16.        cout<<endl;     
  17.     }
  18.     system("pause");
  19.     return 0;   
  20. }
複製代碼

作者: 戴偉宸    時間: 2018-9-12 21:24

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.         int score[5][3]={{90,85,85},{70,75,80},{80,95,80},{70,95,75},{80,85,95}};
  7.         cout<<"座號\t國文\t英文\t數學"<<endl;
  8.         cout<<"============================="<<endl;
  9.         for(int i=0; i<5; i++)
  10.         {
  11.             cout<<i+1<<"\t";
  12.                 for(int j=0; j<3; j++)
  13.                 {
  14.                         cout<<score[i][j]<<"\t";
  15.                 }       
  16.                 cout<<endl;
  17.         }
  18. system("pause");
  19. return 0;
  20. }
複製代碼

作者: 譚詩澐    時間: 2018-9-15 14:02

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int score[5][3]={{90,85,85},{70,75,80},{80,95,80},{70,95,75},{80,85,95}};
  7.     cout<<"座號\t國文\t英文\t數學"<<endl;
  8.     cout<<"============================"<<endl;
  9.     for(int i=0; i<5; i++)
  10.     {
  11.        cout<<i+1<<"\t";
  12.        for(int j=0; j<3; j++)
  13.        {
  14.            cout<<score[i][j]<<"\t";
  15.        }
  16.        cout<<endl;     
  17.     }
  18.     system("pause");
  19.     return 0;   
  20. }
複製代碼

作者: 陳柏霖    時間: 2018-9-15 14:15

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int score[5][3]={{90,85,85},
  7.                      {70,75,80},
  8.                      {80,95,80},
  9.                      {70,95,75},
  10.                      {80,85,95}};
  11.     cout<<"座號\t國語\t英文\t數學\t"<<endl;
  12.     cout<<"==============================="<<endl;
  13.     for(int i=0; i<5; i++)
  14.     {
  15.             cout<<i+1<<"\t";
  16.             for(int j=0; j<3; j++)
  17.             {
  18.                     cout<<score[i][j]<<"\t";
  19.             }
  20.             cout<<endl;
  21.     }
  22.     system("pause");
  23.     return 0;
  24. }
複製代碼

作者: 戴安利    時間: 2018-9-15 14:20

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.    int score[5][3]={{99,98,97},{96,95,94},{93,92,91},{90,89,88},{87,86,85}};
  7.    cout<<"座號\t國文\t英文\t數學"<<endl;
  8.    cout<<"-----------------------------"<<endl;
  9.    for (int i=0; i<5; i++)
  10.    {
  11.       cout<<i+1<<"\t";
  12.       for (int j=0; j<3; j++)
  13.       {
  14.          cout<<score[i][j]<<"\t";
  15.       }
  16.       cout<<endl;
  17.    }

  18. system("pause");
  19. return 0;
  20. }
複製代碼

作者: 戴唯陞    時間: 2018-9-15 14:22

  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.      int score[5][3]={{90,85,85},
  7.                       {70,75,80},
  8.                       {80,95,80},
  9.                       {70,95,75},
  10.                       {80,85,95} };
  11.                      
  12.      cout<<"座號\t國文\t英文\t數學"<<endl;
  13.      cout<<"======================="<<endl;      
  14.      for (int i=0;i<5;i++)
  15.      { cout<<i+1<<"\t";
  16.      
  17.      for (int j=0;j<3;j++)
  18.      {
  19.          cout<<score [i][j]<<"\t";
  20.      }
  21.      cout<<endl;
  22.      }
  23.      
  24.          
  25.       system("pause");
  26.       return 0;
  27. }                 
複製代碼





歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/) Powered by Discuz! 7.2