返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<string>
  4. using namespace std;
  5. int main(){
  6. //<法1一維陣列>
  7. string name[]={"王大明","李大頭","蘇小安","余美美","張醜醜"};

  8. int chinese[] = {90,70,80,70,80};
  9.     int english[] = {85,75,95,95,85};
  10.     int math[] = {85,80,80,75,95};
  11.     cout<<"座號\t姓名\t\t國文\t英文\t數學"<<endl;
  12.     cout<<"============================================"<<endl;

  13.     for(int i=0;i<5;i++)
  14.     {cout<<i+1<<"\t";
  15.     cout<<name[i]<<"\t"<<"\t"<<chinese[i]<<"\t"<<english[i]<<"\t"<<math[i]<<"\t";
  16.     cout<<endl;




  17.     }
  18.     cout<<endl;
  19. //<法2二維陣列>
  20.     int score[5][3] = {
  21.         {90,85,85},
  22.         {70,75,80},
  23.         {80,95,80},
  24.         {70,95,75},
  25.         {80,85,95}
  26.     };
  27.     cout<<"座號\t姓名\t\t國文\t英文\t數學"<<endl;
  28.     cout<<"============================================"<<endl;

  29.     for(int i=0;i<5;i++){
  30.         cout<<i+1<<"\t"<<name[i]<<"\t\t";
  31.         for(int j=0;j<3;j++){
  32.             cout<<score[i][j]<<"\t";
  33.         }
  34.         cout<<endl;
  35.     }


  36. system("pause");
  37. return 0;

  38. }
複製代碼

TOP

返回列表