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

TOP

返回列表