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