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

TOP

返回列表