返回列表 發帖
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.    
  7.     int num [5][4]=
  8.     {
  9.         {1,77,52,77},
  10.         {2,50,95,99},
  11.         {3,56,91,65},
  12.         {4,45,55,69},
  13.         {5,88,59,99}
  14.     };
  15.     cout<<"座號\t國文\t英文\t數學\t總分\t平均"<<endl;
  16.     cout<<"============================================"<<endl;  
  17.    
  18.     for(int i=0; i<5;i++)
  19.     {
  20.     int total=0;
  21.       for(int j=0; j<4;j++)
  22.       {
  23.          cout<<num[i][j]<<"\t";
  24.          if(j!=0)
  25.          {
  26.          total += num[i][j];
  27.          }
  28.       
  29.       }
  30.       cout<<total<<"\t";
  31.       cout<<total/3<<"\t"<<endl;
  32.       cout<<endl;     
  33.     }
  34.    
  35.     system("pause");
  36.      return 0;     
  37. }
複製代碼

TOP

返回列表