|
|
发表于 2012-8-27 11:48:17
|
显示全部楼层
- //#include<iostream.h>
- #include<iostream>
- #include<string>
- using namespace std;
- int main()
- {
- //定义部分
- const int G=2,C=1,X=1;//G:年纪个数 C:班级个数 X:自定义班级人数
- int a,b,c;//用于循环时的年级、班级和座号
- register int o,p,q;
- register int h;//判断是否
- register int e,f,g;// 寄存器变量。查找、删除、更改时年级、班级和座号
- const int I=100;//一个班级最多容纳100人
-
- //界面输出
- cout<<"**********************************"<<endl;
- cout<<"* 学生成绩管理系统 *"<<endl;
- cout<<"*--------------------------------*"<<endl;
- cout<<"*注意 : *"<<endl;
- cout<<"* 该软件各班级仅记录100个学生! *"<<endl;
- cout<<"* 并且要求各年段班级数一致 ! *"<<endl;
- cout<<"**********************************"<<endl;
- cout<<endl;
-
- //cout<<"请输入年级数 :";
- // cin>>G;
- //cout<<"请输入各年级的班级数 :";
- // cin>>C;
- string Na[G][C][I];//名字数组
- float Ch[G][C][I];//语文成绩
- float En[G][C][I];//英语成绩
- float Ma[G][C][I];//数学成绩
- double Total_C[G][C];//各班总成绩
- double Total_G[G];//各年段总成绩
- //主界面
- ZJM://转向语句语句标号在此!!!
- cout<<"1、录入学生成绩"<<endl;
- cout<<"2、更改学生成绩"<<endl;
- cout<<"3、删除学生成绩"<<endl;
- cout<<"4、查看学生成绩"<<endl;
- cout<<"5、添加学生成绩"<<endl;
- cout<<"请输入 : ";
- int j;
- cin>>j;
- if(j==1)
- goto RR;
- else if(j==2)
- goto GG;
- else if(j==3)
- goto SC;
- else if(j==4)
- goto CK;
- else if(j==5)
- goto TJ;
- else
- {
- cout<<"输入错误!"<<endl;
- goto ZJM;
- }
- //1、录入学生成绩
- //goto语句标号于此,以条件语句和转向语句循环年级、班级
- cout<<"请输入"<<a+1<<"年"<<b+1<<"班成绩"<<endl;
- //cout<<"请输入该班级人数 : ";
- //cin>>X;
- a=0;
- b=0;
-
- RR:
- for(c=0;c<X;c++)
- {
- cout<<"学生姓名 : ";
- cin>>Na[a][b][c];
- cout<<"请输入语文成绩 : ";
- cin>>o;
- Ch[a][b][c]=o;
- cout<<'\n'<<"请输入数学成绩 : ";
- cin>>p;
- Ma[a][b][c]=p;
- cout<<'\n'<<"请输入英语成绩 : ";
- cin>>q;
- En[a][b][c]=q;
- cout<<endl;
- for(int d=0;d<c;d++)
- {
- Total_C[a][b]+=(Ch[a][b][d]+Ma[a][b][d]+En[a][b][d]);
- //计算班级总分
- }
- }
- PD:
- cout<<"返回主界面或继续输入下一个班级成绩?"<<endl;;
- cout<<"1 :返回主界面 0 :继续下一个班级成绩"<<endl;
- cout<<"请选择 : ";
- cin>>h;
- if (h==1)
- {
- _sleep(1000);
- goto ZJM;//返回主界面
- }
- else if (h==0)
- {
- if(a<G+1&&b<C+1)//班级数加1,录入下一个班级成绩
- {
- b++;
- goto RR;
- }
- if(a<G+1&&b==C+1)//该年级录入完成,录入下一个年级
- {
- a++;
- b=0;
- goto RR;
- }
- else//全部录入完成
- {
- cout<<"成绩录入完成,返回主界面"<<endl;
- _sleep(1000);
- goto ZJM;
- }
- }
- else
- {
- cout<<"错误!"<<endl;
- _sleep(1000);
- goto PD;
- }
-
-
- //2、更改学生成绩
- //goto语句标号于此,以条件语句和转向语句循环年级、班级
- GG:
- cout<<"请输入年级 : ";
- cin>>e;
- cout<<'\n'<<"请输入班级 : ";
- cin>>f;
- cout<<'\n'<<"请输入座号 : ";
- cin>>g;
- cout<<"原来成绩为 : "<<endl;
- cout<<Na[e][f][g]<<" : ";
- cout<<"语文 "<<Ch[e][f][g]<<" , 数学"<<Ma[e][f][g]<<" , 英语"<<En[e][f][g];
- cout<<"请输入新成绩 :"<<endl;
- cout<<"请输入语文成绩 : ";
- cin>>Ch[e][f][g];
- cout<<'\n'<<"请输入数学成绩 : ";
- cin>>Ma[e][f][g];
- cout<<'\n'<<"请输入英语成绩 : ";
- cin>>En[e][f][g];
- GGFJ:
- cout<<"是否继续更改其他学生的成绩?"<<endl;
- cout<<"1:是 0:否,返回主界面"<<endl;
- cout<<"请输入 : ";
- cin>>h;
- if (h==1)
- {
- _sleep(1000);
- goto GG;
- }
- else if(h==0)
- {
- _sleep(1000);
- goto ZJM;
- }
- else
- {
- cout<<"错误!"<<endl;
- goto GGFJ;
- }
-
- //3、删除学生成绩
- //goto语句标号于此,以条件语句和转向语句循环年级、班级
- SC:
- cout<<"请输入年级 : ";
- cin>>e;
- cout<<'\n'<<"请输入班级 : ";
- cin>>f;
- cout<<'\n'<<"请输入座号 : ";
- cin>>g;
- cout<<endl;
- cout<<Na[e][f][g]<<" : ";
- cout<<"语文 "<<Ch[e][f][g]<<" , 数学"<<Ma[e][f][g]<<" , 英语"<<En[e][f][g];
- SCFJ:
- cout<<"确定删除?"<<endl;
- cout<<"1:是 0:否"<<endl;
- cout<<"请输入 : ";
- cin>>h;
- if (h==1)
- {
- Ch[e][f][g]=0;
- Ma[e][f][g]=0;
- En[e][f][g]=0;
- cout<<"操作成功!"<<endl;
- SCFJJ:
- cout<<"是否返回主界面?"<<endl;
- cout<<"1:是 0:否"<<endl;
- cout<<"请输入 : ";
- cin>>h;
- if(h==1)
- {
- _sleep(1000);
- goto ZJM;
- }
- else if(h==0)
- {
- _sleep(1000);
- goto SC;
- }
- else
- {
- cout<<"错误!"<<endl;
- goto SCFJJ;
- }
- }
- else if (h==0)
- {
- _sleep(1000);
- goto SC;
- }
- else
- {
- cout<<"错误!"<<endl;
- goto SCFJ;
- }
-
- //4、查看学生成绩
- //goto语句标号于此,以条件语句和转向语句循环年级、班级
- CK:
- cout<<"请注意只能查看一个班级全部学生的成绩!"<<endl;
- cout<<"请输入年级 :";
- cin>>e;
- cout<<'\n'<<"请输入班级 :";
- cin>>f;
- {//加这个是由于VC6的bug
- for(int x=0;x<=X;x++)
- {
- cout<<Na[e][f][x]<<" : ";
- cout<<"语文 "<<Ch[e][f][x]<<" , 数学"<<Ma[e][f][x]<<" , 英语"<<En[e][f][x];
- }
- }
- CKFJ:
- cout<<"是否继续查看其他班级?"<<endl;
- cout<<"1:是 0:否,返回主界面"<<endl;
- cout<<"请输入 : ";
- cin>>h;
- if(h==1)
- {
- _sleep(1000);
- goto CK;
- }
- else if(h==0)
- {
- _sleep(1000);
- goto ZJM;
- }
- else
- {
- cout<<"错误!"<<endl;
- goto CKFJ;
- }
- //5、添加学生成绩
- //goto语句标号于此,以条件语句和转向语句循环年级、班级
- TJ:
- cout<<"请输入年级 : "<<endl;
- cin>>e;
- cout<<"请输入班级 : "<<endl;
- cin>>f;
- cout<<"请输入座号 : "<<endl;
- cin>>g;
- if (Na[e][f][g]!="\0")
- {
- cout<<"该数组已经有数据了!"<<endl;
- goto TJ;
- }
- cout<<"请输入语文成绩 : ";
- cin>>Ch[e][f][g];
- cout<<'\n'<<"请输入数学成绩 : ";
- cin>>Ma[e][f][g];
- cout<<'\n'<<"请输入英语成绩 : ";
- cin>>En[e][f][g];
- cout<<"是否继续添加学生成绩?"<<endl;
- cout<<"1:是 0:否,返回主界面"<<endl;
- cout<<"请输入 : ";
- cin>>h;
- if(h==1)
- {
- _sleep(1000);
- goto TJ;
- }
- else if(h==0)
- {
- _sleep(1000);
- goto ZJM;
- }
- else
- {
- cout<<"错误!"<<endl;
- goto TJ;
- }
- return 0;
- }
复制代码 |
|