返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int x,y,score;
  7.     string sub[5]={"國文","英文","數學","物理","化學"};
  8.     string name[5]={"甲","乙","丙","丁","戊"};
  9.     int array[5][5]={{100,100,100,100,5},{45,56,82,95,46},{78,90,86,65,85},{75,91,56,99,55},{45,72,54,45,24}};
  10.     cout<<"請問要調查哪位同學的成績?(甲:1,乙:2,丙:3,丁:4,戊:5)"<<endl;
  11.     cin>>x;
  12.     while(x!=-1){
  13.         cout<<"請問要調查哪個科目?(國文:1,英文:2,數學:3,物理:4,化學:5)"<<endl;
  14.         cin>>y;
  15.         cout<<name[x-1]<<" "<<sub[y-1]<<" "<<array[x-1][y-1]<<"分"<<endl;
  16.         cout<<"請問要修改成幾分: ";
  17.         cin>>score;
  18.         array[x-1][y-1]=score;      
  19.         cout<<"請問要調查哪位同學的成績?(甲:1,乙:2,丙:3,丁:4,戊:5)"<<endl;
  20.         cin>>x;
  21.     }
  22.     system("cls");
  23.     cout<<"學號\t姓名\t";
  24.     for(int a=0;a<5;a++)
  25.         {
  26.                 cout<<sub[a]<<"\t";     
  27.         }   
  28.         cout<<endl;
  29.         cout<<"======================================================"<<endl;
  30.     for(int c=0;c<5;c++)
  31.         {
  32.                 cout<<"  "<<c+1<<"       "<<name[c]<<"   ";
  33.                 for(int d=0;d<5;d++)
  34.                 {
  35.                     cout<<"  "<<array[c][d]<<"\t";
  36.                 }
  37.          cout<<endl;
  38.          }
  39.    
  40.     system("pause");
  41.     return 0;
  42. }
複製代碼

TOP

返回列表