返回列表 發帖

[作業] 陣列 (八) - 成績表 (三)

本帖最後由 tonyh 於 2015-9-11 21:33 編輯

新增平均欄位.



本帖隱藏的內容需要回復才可以瀏覽
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {       
  6.         string name[5] = {"王大明","王曉明","余美美","張醜醜","裡大頭"};
  7.         int score[5][4] = {{43,45,77,0},{76,77,43,0},{78,11,22,0},{43,89,88,0},{98,44,67,0}};
  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.                 {
  16.                         cout << score[i][j] << "\t";
  17.                 }
  18.                 cout << endl;
  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.     int score[5][4]={{43,55,77,0},{76,77,43,0},{78,11,22,0},{43,89,88,0},{98,44,67,0}};
  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.     system("pause");   
  19.     return 0;
  20. }
複製代碼
我是眾神之王XXX  I love you
0000000000

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main(){
  5.     string name[]={"王大明","王忠明","王曉明","王小小","王維曉"};
  6.     float score[5][4]={{90,85,85,0},
  7.                      {100,44,95,0},
  8.                      {45,65,100,0},
  9.                      {92,58,100,0},
  10.                      {100,100,100,0}};
  11.     cout<<"座號\t姓名\t\t國文\t英文\t數學\t平均"<<endl;
  12.     cout<<"****************************************************"<<endl;
  13.     for(int i=0; i<=4; i++){
  14.        cout<<i+1<<"\t"<<name[i]<<"\t\t";
  15.        score[i][3]=(score[i][0]+score[i][1]+score[i][2])/3;
  16.        for(int j=0; j<=3; j++)      
  17.           printf("%.2f\t",score[i][j]);
  18.        cout<<endl;     
  19.     }
  20.     system("pause");   
  21.     return 0;
  22. }
複製代碼
ABCDEFGHIJKLMNOPQRSTUVWXYZ

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string name[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
  7.     float score[5][4]={{43,55,77,0},{76,77,43,0},{78,11,22,0},{43,89,88,0},{98,44,67,0}};
  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.     system("pause");   
  19.     return 0;
  20. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string name[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
  7.     int score[5][4]={{43,55,77,0},{76,77,43,0},{78,11,22,0},{43,89,88,0},{98,44,67,0}};
  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.     system("pause");   
  19.     return 0;
  20. }
複製代碼

TOP

返回列表