Board logo

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

作者: tonyh    時間: 2014-1-18 16:56     標題: 陣列 (六) - 成績表 (一)

本帖最後由 tonyh 於 2014-1-18 17:23 編輯

利用二維陣列, 試做一個包含五位同學, 各三組分數的成績表格.
表格的形式如下:
[attach]808[/attach]
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     float 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<=4; i++)
  14.     {
  15.         cout<<i+1<<"\t";
  16.         for(int j=0; j<=2; j++)
  17.         {
  18.             cout<<score[i][j]<<"\t";   
  19.         }     
  20.         cout<<endl;
  21.     }
  22.     system("pause");
  23.     return 0;   
  24. }
複製代碼

作者: 施伯叡    時間: 2014-1-18 17:13

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

作者: 張郁庭    時間: 2014-1-18 17:15

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

作者: 張峻瑋    時間: 2014-1-18 17:16

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

作者: 張郁偵    時間: 2014-1-18 17:22

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.   float a[5][3]={{100,100,100},
  7.                  {100,100,100},         
  8.                  {100,100,100},
  9.                  {100,100,100},         
  10.                  {100,100,100}};
  11.   cout<<"Number \tChinese\tEnglish\tMath\t"<<endl;
  12.   cout<<"-------------------------------------------------------"<<endl;
  13.   for(int i=0; i<=4; i++)
  14.   {
  15.          cout<<i+1<<"\t";
  16.          for(int j=0; j<=2 ;j++)  
  17.           {
  18.                   cout<<a[i][j]<<"\t";
  19.           }
  20.           cout<<endl;
  21.   }              
  22.   system ("pause");   
  23.   return 0;
  24. }
複製代碼

作者: 張彥承    時間: 2014-1-18 17:25

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

作者: 劉得旗    時間: 2014-1-24 18:56

本帖最後由 劉得旗 於 2014-1-24 19:40 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int a[5][3]=   {{ 93 , 85 , 88 },
  7.                     { 81 , 74 , 97 },
  8.                     { 80 , 85 , 70 },
  9.                     { 58 , 97 , 88 },
  10.                     { 84 , 99 , 47 }};
  11.     cout<<"座號\t國文\t英文\t數學\t"<<endl;
  12.     cout<<"*****************************"<<endl;               
  13.     for(int i=0;i<=4;i++)
  14.     {
  15.         cout<<i+1<<"\t";     
  16.         for(int j=0;j<=2;j++)  
  17.         {
  18.             cout<<a[i][j]<<"\t";
  19.         }
  20.         cout<<endl;
  21.     }                        
  22.     system("pause");
  23.     return 0;   
  24. }
複製代碼

作者: 周雍程    時間: 2014-1-24 19:47

  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;

  4. int main()
  5. {
  6.     float score[5][3]={{90,98,89},
  7.                        {76,83,85},
  8.                        {91,87,94},
  9.                        {76,82,78},
  10.                        {91,86,95}};
  11.     cout<<"座號\t國文\t英文\t數學\t"<<endl;
  12.     cout<<"============================"<<endl;
  13.     for(int i=0; i<=4; i++)
  14.     {      
  15.             cout<<i+1<<"\t";
  16.             for(int j=0; j<=2; j++)  
  17.             {
  18.                  cout<<score[i][j]<<"\t";
  19.             }        
  20.             cout<<endl;
  21.     }
  22.     system("pause");
  23.     return 0;
  24. }
複製代碼





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