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

TOP

返回列表