返回列表 發帖

陣列 (七) - 成績表 (三)

本帖最後由 陳品肇 於 2019-2-1 21:20 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string name[5]={"王一美","王二美","王三美","王四美","王五美"};
  7.     float score[5][4] ={{90,90,85,0} ,
  8.     {70,75,85,0},
  9.     {80,95,80,0},
  10.     {70,95,75,0},
  11.     {80,85,95,0}};
  12.    
  13.     cout<<"座號\t姓名\t\t國文\t英文\t數學\t平均"<<endl;
  14.     cout<<"===================================================="<<endl;
  15.     for(int i=0;i<5;i++)
  16.     {
  17.          cout<<i+1<<"\t";   // 印座號
  18.          cout<< name[i]<<"\t\t";    //印姓名
  19.          //[0][3]=    ([0][0]+[0][1]+[0][2])/3
  20.          score[i][3] = (score[i][0]+score[i][1]+score[i][2])/3; //算出平均
  21.          for(int j=0;j<4;j++)
  22.          {
  23.             cout<<score[i][j]<<"\t";  //印出成績
  24.          }
  25.          cout<<endl;
  26.     }

  27.     system("pause");
  28.     return 0;
  29. }
複製代碼
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

本帖最後由 曲書辰 於 2019-2-2 15:12 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     float n[5][4]={{90,85,85,0},
  7.                    {70,75,80,0},
  8.                    {80,95,80,0},
  9.                    {70,95,75,0},
  10.                    {80,85,95,0}};
  11.     string n4[5]={"王大明","李大頭","蘇小美","余美美","張醜醜"};
  12.    
  13.    
  14.     cout<<"座號\t姓名\t\t國文\t英文\t數學\t平均"<<endl;
  15.     cout<<"==========================================================="<<endl;
  16.     for(int i=0;i<5;i++)
  17.     {
  18.       n[i][3]=(n[i][0]+n[i][1]+n[i][2])/3;
  19.       
  20.       cout<<i+1<<"\t";
  21.       cout<<n4[i]<<"\t\t";
  22.       for(int j=0;j<4;j++)      
  23.       {  
  24.               cout<<n[i][j]<<"\t";   
  25.       }
  26.       cout<<endl;     
  27.     }
  28.    
  29.     system("pause");
  30.     return 0;
  31. }  
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string name[5]={"王一美","王二美","王三美","王四美","王五美"};
  7.     float f[5][4]={{90,90,85,0},
  8.                  {70,75,85,0},
  9.                  {80,95,80,0},
  10.                  {70,95,75,0},
  11.                  {80,85,95,0}};
  12.     cout<<"座號\t姓名\t\t國文\t英文\t數學\t平均"<<endl;
  13.     cout<<"===================================================="<<endl;
  14.    
  15.     for(int i=0;i<5;i++)
  16.     {
  17.             cout<<i+1<<"\t";
  18.             cout<<name[i]<<"\t\t";
  19.             f[i][3]=(f[i][0]+f[i][1]+f[i][2])/3;
  20.             for(int j=0;j<4;j++)
  21.             {
  22.                     cout<<f[i][j]<<"\t";
  23.             }
  24.             cout<<endl;
  25.     }

  26.    
  27.     system("pause");
  28.     return 0;
  29. }
複製代碼
回復 1# 陳品肇

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     float a[5][4]={{90,90,85,0},{70,75,85,0},{80,95,80,0},{70,95,75,0},{80,85,95,0}};
  7.     string b[5]={"王一美","王二美","王三美","王四美","王五美"};
  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"<<b[i]<<"\t\t";
  13.         a[i][3]=(a[i][0]+a[i][1]+a[i][2])/3;
  14.         for(int j=0;j<4;j++)
  15.         {
  16.             cout<<a[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.   float n[5][4]={{90,85,85,0},
  7.                {70,75,80,0},
  8.                {80,95,80,0},
  9.                {70,95,75,0},
  10.                {80,85,95,0}};
  11.   
  12.   string b[5]={"王大明","李大頭","蘇小安","余美美","張醜醜"};
  13.   cout<<"座號\t姓名\t國文\t英文\t數學\t平均"<<endl;
  14.   
  15.   for(int i=0;i<5;i++)
  16.   {
  17.     n[i][3]=(n[i][0]+n[i][1]+n[i][2])/3;
  18.     cout<<i+1<<"\t"<< b[i]<<"\t";
  19.     for(int j=0;j<4;j++)
  20.     {
  21.     cout<<n[i][j]<<"\t";        
  22.     }      
  23.     cout<<endl;
  24.   }   
  25.   system("pause");
  26.   return 0;
  27. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {   string name[5]={"王一美","王二美","王三美","王四美","王五美"};
  6.     float score[5][4]={{90,90,85,0},{70,75,85,0},{80,95,80,0},{80,85,95,0},{70,95,75,0}};
  7.     cout<<"座號\t姓名\t國文\t英文\t數學\t平均"<<endl;
  8.      cout<<"==========================================="<<endl;
  9.      for(int i=0;i<5;i++)
  10.      {
  11.      cout<<i+1<<"\t";
  12.      cout<<name[i]<<"\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.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  21.     system("pause");
  22.     return 0;
  23. }  
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     float s[5][4]={{90,90,85,0},{70,75,85,0},{80,95,80,0},{70,95,75,0},{80,85,95,0}};
  7.     string n[5]={"王一美","王二美","王三美","王四美","王五美"};
  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";
  13.        cout<<n[i]<<"\t\t";
  14.        s[i][3]=(s[i][0]+s[i][1]+s[i][2])/3;
  15.        for(int j=0;j<4;j++)
  16.        {
  17.              cout<<s[i][j]<<"\t";   
  18.        }
  19.        cout<<endl;
  20.     }
  21.     system("pause");
  22.     return 0;        
  23. }
複製代碼

TOP

返回列表