- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int x,y,z;
- string sub[5]={"國文","英文","數學","物理","化學"};
- cout<<"座號 姓名 ";
- for(int a=0;a<5;a++)
- {
- cout<<sub[a]<<"\t";
- }
- cout<<endl;
- cout<<"======================================================"<<endl;
- string name[5]={"甲","乙","丙","丁","戊"};
- 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}};
- for(int c=0;c<5;c++)
- {
- cout<<" "<<c+1<<" "<<name[c]<<" ";
- for(int d=0;d<5;d++)
- {
- cout<<" "<<array[c][d]<<"\t";
- }
- cout<<endl;
- }
- cout<<endl;
- cout<<"請問要調查哪位同學的成績?(甲:1,乙:2,丙:3,丁:4,戊:5)"<<endl;
- cin>>x;
- cout<<"請問要調查哪個科目?(國文:1,英文:2,數學:3,物理:4,化學:5)"<<endl;
- cin>>y;
- cout<<name[x-1]<<"同學"<<sub[y-1]<<array[x-1][y-1]<<"分"<<endl;
- cout<<"請問要修改幾分?"<<endl;
- cin>>z;
- array[x-1][y-1]=z;
- cout<<"座號 姓名 ";
- for(int a=0;a<5;a++)
- {
- cout<<sub[a]<<"\t";
- }
- cout<<endl;
- cout<<"======================================================"<<endl;
- for(int c=0;c<5;c++)
- {
- cout<<" "<<c+1<<" "<<name[c]<<" ";
- for(int d=0;d<5;d++)
- {
- cout<<" "<<array[c][d]<<"\t";
- }
- cout<<endl;
- }
- cout<<endl;
- system("pause");
- return 0;
- }
複製代碼 |