返回列表 發帖

陣列 (六) - 成績表 1

利用二維陣列,試做一個包含五位同學,各三組分數的成績表格。
表格的形式如下:

  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.     {
  16.         cout<<i+1<<"\t";
  17.         for(int j=0; j<3; j++)
  18.              cout<<score[i][j]<<"\t";
  19.         cout<<endl;
  20.     }
  21.     system("pause");
  22.     return 0;
  23. }
複製代碼

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string name[5]{"王大明","李大頭","蘇小安","余美美","張醜醜"};
  7.     float score[5][4]={{90,85,85,0},
  8.                      {70,75,80,0},
  9.                      {80,95,80,0},
  10.                      {70,95,75,0},
  11.                      {80,85,95,0}};
  12.    
  13.     cout<<"座號\t姓名\t\t國文\t英文\t數學\t平均"<<endl;
  14.     cout<<"======================================"<<endl;
  15.     for(int i=0; i<5; i++)
  16.     {
  17.         cout<<i+1<<"\t"<<name[i]<<"\t\t";
  18.         for(int j=0; j<4; j++)
  19.         {
  20.              cout<<score[i][j]<<"\t";
  21.         }
  22.         cout<<endl;
  23.     }
  24.     system("pause");
  25.     return 0;
  26. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int s[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.             cout<<s[i][j]<<"\t";
  14.         cout<<endl;      
  15.     }  

  16.     system("pause");
  17.     return 0;
  18. }
複製代碼

TOP

  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.     {
  16.         cout<<i+1<<"\t";
  17.         for(int j=0; j<3; j++)
  18.              cout<<score[i][j]<<"\t";
  19.         cout<<endl;
  20.     }
  21.     system("pause");
  22.     return 0;
  23. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n[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<<n[i][j]<<"\t";
  19.        }
  20.        cout<<endl;
  21.     }
  22.     system("pause");
  23.     return 0;
  24. }
複製代碼
hahahahahahahaha

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int h[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 u=0; u<3; u++)
  13.       {
  14.         cout<<h[i][u]<<"\t";        
  15.       }
  16.       cout<<"\n";                  
  17.     }
  18.     system("pause");
  19.     return 0;
  20. }
複製代碼

TOP

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

TOP

  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 a=0; a<5; a++)
  15.     {
  16.         cout<<a+1<<"\t";
  17.         for(int b=0; b<3; b++)
  18.              cout<<score[a][b]<<"\t";
  19.         cout<<endl;
  20.     }
  21.     system("pause");
  22.     return 0;
  23. }
複製代碼
李宇澤Oscar

TOP

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

TOP

  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.             cout<<score[i][j]<<"\t";
  18.         cout<<endl;
  19.     }
  20.     system("pause");
  21.     return 0;
  22. }
複製代碼
Huang chenhao

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int x[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 f=0; f<5; f++)
  10.     {
  11.         cout<<f+1<<"\t";
  12.         for(int j=0; j<3; j++)
  13.              cout<<x[f][j]<<"\t";
  14.         cout<<endl;
  15.     }
  16.     system("pause");
  17.     return 0;
  18. }
複製代碼

TOP

返回列表