返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string name[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
  7.     int score[5][3]={{43,55,77},{76,77,43},{78,11,22},{43,89,88},{98,44,67}};
  8.     cout<<"座號\t姓名\t\t國文\t英文\t數學\t平均"<<endl;
  9.     cout<<"========================================================"<<endl;
  10.     for(int i=0; i<5; i++)
  11.     {
  12.          cout<<i+1<<"\t"<<name[i]<<"\t\t";
  13.          for(int j=0; j<3; j++)
  14.               {cout<<score[i][j]<<"\t";
  15.       
  16.          cout<<endl;}
  17.           cout<<score[i][j]/3<<"\t";
  18.     }
  19.    
  20.     system("pause");
  21.     return 0;
  22. }
複製代碼

TOP

  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},{70,75,80},{80,95,80},{70,95,75},{80,85,95}};
  8.     cout<<"座號\t姓名\t\t國文\t英文\t數學\t平均"<<endl;
  9.     cout<<"========================================================"<<endl;
  10.     for(int i=0; i<5; i++)
  11.     {
  12.          cout<<i+1<<"\t"<<name[i]<<"\t\t";
  13.          score[i][3]=(score[i][0]+score[i][1]+score[i][2])/3;
  14.          for(int j=0; j<4; j++)
  15.               cout<<score[i][j]<<"\t";
  16.          cout<<endl;
  17.     }
  18.    
  19.     system("pause");
  20.     return 0;
  21. }
複製代碼

TOP

返回列表