那去应付应付吧。本来还想再添加点模块来完善这个程序,但时间与精力毕竟有限,这些也基本上能满足要求了。 <<"英语:"< <<"数学:"< <<"电脑:"< cout<
#include
#include
#include
int N;
class student{
private:
char *name;
int number,Class;
int chinese,math,english,computer;
public:
student(){};
void putin(int cl,int nu,char n[10],int ch,int en,int ma,int co)
{
name=new char[strlen(n)+1];
strcpy(name,n);
number=nu;
math=ma;
english=en;
chinese=ch;
computer=co;
Class=cl;
};
void putna(char *x)
{
name=new char[strlen(x)+1];
strcpy(name,x);
};
void putfour(int x,int y,int z,int h)//传四个成绩
{chinese=x;english=y;math=z;computer=h;};
void putcl(int x){Class=x;};// 赋一个值,下面同样
void putnu(int x){number=x;};
void putch(int x){chinese=x;};
void puten(int x){english=x;};
void putma(int x){math=x;};
void putco(int x){computer=x;};
int getcl(){return Class;};//返回一个值,下面同样
int getnu(){return number;};
int getch(){return chinese;};
int geten(){return english;};
int getma(){return math;};
int getco(){return computer;};
char *getna(){return(name);};
void putout(){//返回全部资料
cout<
};
};
//*******************************************************
// 汇总
//*******************************************************
double average(student *p,char *na,int Cl)//每一个科目的平均分
{
float av=0,j1=1;int j=0;
for(int i=0;i
{av=av+p[i].getch();++j;j1=float(j);}
if(strcmp(na,"英语")==0&&p[i].getcl()==Cl)
{av=av+p[i].geten();++j;j1=float(j);}
if(strcmp(na,"电脑")==0&&p[i].getcl()==Cl)
{av=av+p[i].getco();++j;j1=float(j);}
if(strcmp(na,"数学")==0&&p[i].getcl()==Cl)
{av=av+p[i].getma();++j;j1=float(j);}
}
if(av==0) return 0;
else return av/j1;
}
int sum(student p)//每人的总分
{
int s=0;
s=p.getch()+p.geten()+p.getco()+p.getma();
return s;
}
//***************************************************************
int find(student *p,int Cl,int Nu)//通过班级和学号,对要修改的对象返回它的对象里的值
{
int i=0,a=N+1;
for(;i
if(p[i].getcl()==Cl&&p[i].getnu()==Nu)
{
a=i;break;
}
else continue;
}
if(a!=N+1)return a;
else return N;
}
int find(student *p,int Cl,char *Na)//通过班级和名字,对要修改的对象返回它的对象里的值
{
int i=0,a=N+1;
for(;i
{
a=i;break;
}
if(a!=N+1)return a;
else return N;
}
int find(student *p,char *Na,int Nu)//通过名字和学号,对要修改的对象返回它的对象里的值
{
int i=0,a=N+1;
for(;i
{
a=i;break;
}
if(a!=N+1)return a;
else return N;
}
int find(student *p,int Cl)//通过班,对要修改的对象返回它的对象里的值
{
int i=0,a=N+1;
for(;i
{
a=i;break;
}
if(a!=N+1)return a;
else return N;
}
//*******************************************************************
// 查询成绩
//*******************************************************************
void search(student *p,int Cl,char *Na)//通过班级和名字,来查询成绩
{
int j=find(p,Cl,Na);
if(j==N) cout<
{
cout<
cout<
cout<
}
}
void search(student *p,char *Na,int Nu)//通过名字和学号,来查询成绩
{
int j=find(p,Na,Nu),a4;float a5;
if(j==N) cout<
{
cout<<"班级"<
cout<
cout<
}
void search(student *p,int Cl,int Nu)//通过班和号,来查询成绩
{
int j=find(p,Cl,Nu);
if(j==N) cout<
{
cout<<"班级"<
cout<
cout<
//8888888888888888888888888888888888888888888888888888888
void lank(student *p,int Cl)//按学号顺序排
{
int k1,k2,k3,k4,k5,k6;char *k7;
for(int i=0;i
for(int j=i+1;j
{
k1=p[i].getcl();p[i].putcl(p[i+1].getcl());p[j].putcl(k1);
k7=new char[strlen(p[i].getna())+1];
strcpy(k7,p[i].getna());p[i].putna(p[i+1].getna());p[i+1].putna(k7);
k2=p[i].getnu();p[i].putnu(p[j].getnu());p[j].putnu(k2);
k3=p[i].getch();p[i].putch(p[j].getch());p[j].putch(k3);
k4=p[i].geten();p[i].puten(p[j].geten());p[j].puten(k4);
k5=p[i].getma();p[i].putma(p[j].getma());p[j].putma(k5);
k6=p[i].getco();p[i].putco(p[j].getco());p[j].putco(k6);
}
else continue;
}
}
//***********************************************
void search(student *p,int Cl)//查某班级的成绩,是按学号顺序排
{
int k8=find(p,Cl);
lank(p,Cl);
if(k8==N) cout<
{cout<<"班级"<
{
int A1;float A2;
A1=sum(p[i]);A2=float(A1)/4;
p[i].putout();cout<
}
//******************************************************************
void change(student *p,int Cl,int Nu,char *Na)//修改成绩
{
int a=find(p,Cl,Nu);
int C,B1,B2,B3,B4;
if(a==N) cout<
{
cout<
switch(C)
{
case 1:cout<
cin>>B1;p[a].putch(B1);
cout<
case 2:cout<
cin>>B1;p[a].puten(B1);
cout<
case 3:cout<
cin>>B1;p[a].putma(B1);
cout<
case 4:cout<
cin>>B1;p[a].putco(B1);
cout<
case 5:cout<
cout<<"请输入英语的值:";cin>>B2;
cout<<"请输入数学的值:";cin>>B3;
cout<<"请输入电脑的值:";cin>>B4;
p[a].putfour(B1,B2,B3,B4);
cout<
}
}
}
//*******************************************************
void rank(student *p,int Cl)//通过比较来排名,查看某班的成绩
{
int k1,k2,k3,k4,k5,k6,k8;char *k7;
lank(p,Cl);
for(int i=0;i
for(int j=i+1;j
if(p[i].getcl()==Cl&&p[j].getcl()==Cl&&sum(p[i])<=sum(p[j]))//用学号来排序后,通过总分来比较排名
{
k1=p[i].getcl();p[i].putcl(p[j].getcl());p[j].putcl(k1);
k7=new char[strlen(p[i].getna())+1];
strcpy(k7,p[i].getna());p[i].putna(p[j].getna());p[j].putna(k7);
k2=p[i].getnu();p[i].putnu(p[j].getnu());p[j].putnu(k2);
k3=p[i].getch();p[i].putch(p[j].getch());p[j].putch(k3);
k4=p[i].geten();p[i].puten(p[j].geten());p[j].puten(k4);
k5=p[i].getma();p[i].putma(p[j].getma());p[j].putma(k5);
k6=p[i].getco();p[i].putco(p[j].getco());p[j].putco(k6);
}
else continue;
}
}
k8=find(p,Cl);
if(k8==N) cout<
{
cout<<"名次"<
for(i=0;i
{
int A1;
float A2;
j1++;
A1=sum(p[i]);A2=float(A1)/4;cout<
}}
//888888888888888888888888888888888888888888888888888888888888
void fun(student *pupil)
{
for(int j=0;;j++)//对系统的操作
{
cout<
char p2[10],a0[3];
cin>>a0;
cout<<"*****************************************************************************"<
{
for(int i=0;;i++)
{
cout<
cout<<"请输入你的学号:";cin>>p4;
cout<<"请输入你的名字:";cin>>p2;
change(pupil,p3,p4,p2);
cout<
cin>>b0;
if(strcmp(b0,"Y")==0||strcmp(b0,"y")==0) continue;
else break;
}
cout<<"*****************************************************************************";
}
else if(strcmp(a0,"2")==0)//查询成绩
{
for(int i=0;;i++)
{
cout<
char E5[10];
cin>>E2;
switch(E2)
{
case 1:for(i=0;;i++)
{
cout<
cout<<"请输入姓名:";cin>>E5;
search(pupil,E4,E5);
cout<
if(strcmp(t3,"Y")==0||strcmp(t3,"y")==0) continue;
else break;
}
break;
case 2:for(i=0;;i++)
{
cout<
cout<<"请输入学号:";cin>>E3;
search(pupil,E4,E3);
cout<
if(strcmp(t2,"Y")==0||strcmp(t2,"y")==0) continue;
else break;
}
break;
case 3:for(i=0;;i++)
{
cout<
cout<<"请输入姓名:";cin>>E5;
search(pupil,E5,E3);
cout<
if(strcmp(t1,"Y")==0||strcmp(t1,"y")==0) continue;
else break;
}
break;
case 4:for(i=0;;i++)
{
cout<
search(pupil,E3);
cout<
cin>>m1;
if(strcmp(m1,"Y")==0||strcmp(m1,"y")==0) continue;
else break;
}
break;
case 5: for(i=0;;i++)
{
cout<
cout<<"请输入科目:";cin>>h1;
cout<<"请输入班级:";cin>>h2;
double a3=average(pupil,h1,h2);
if(a3==0) cout<
{cout< cout<
cin>>h3;
if(strcmp(h3,"Y")==0||strcmp(h3,"y")==0)continue;
else break;
}
break;
case 6:for(i=0;;i++)
{
cout<
cin>>u0;
rank(pupil,u0);
cout<
cin>>u1;
if(strcmp(u1,"Y")==0||strcmp(u1,"y")==0) continue;
else break;
}
break;
}
cout<
cin>>b2;
if(strcmp(b2,"Y")==0||strcmp(b2,"y")==0)
{cout<<"*****************************************************************************";
continue;}
else break;
}
}
else break;
cout<
cin>>b1;
if(strcmp(b1,"Y")==0||strcmp(b1,"y")==0) {
cout<<"*****************************************************************************"<
else break;
}}
//***************************************************
void main()
{ cout<
student *pupil=new student[N+10];//用动态数组自己设空间
char (*Name)[10]=new char[N+10][10];//用动态数组自己设空间
int *CL=new int[N+10],*NU=new int[N+10],*CH=new int[N+10],*EN=new int[N+10],*MA=new int[N+10],*CO=new int[N+10];
for(int i=0;i
cout<
cout<<"请输入学号:";cin>>NU[i];
cout<<"请输入姓名:";cin>>Name[i];
cout<
cout<<"请输入英语成绩:";cin>>EN[i];
cout<<"请输入数学成绩:";cin>>MA[i];
cout<<"请输入电脑成绩:";cin>>CO[i];
pupil[i].putin(CL[i],NU[i],Name[i],CH[i],EN[i],MA[i],CO[i]);}
cout<
cout<
char u[3];
cin>>u;
//888888888888888888888888888888888888888888888888888888888888888
for(i=0;;i++)
{
if(strcmp(u,"Y")==0||strcmp(u,"y")==0)//添加和删除
{
char u0[3];
cout<<"添加“1”;删除“2”:";
cin>>u0;
if(strcmp(u0,"1")==0)
{
int u1;
cout<<"请输入你要添加的人数:";
cin>>u1;
N=N+u1;
for(i=u1;i>0;i--)
{
cout<
cout<<"请输入学号:";cin>>NU[N-i];
cout<<"请输入姓名:";cin>>Name[N-i];
cout<
cout<<"请输入英语成绩:";cin>>EN[N-i];
cout<<"请输入数学成绩:";cin>>MA[N-i];
cout<<"请输入电脑成绩:";cin>>CO[N-i];
pupil[N-i].putin(CL[N-i],NU[N-i],Name[N-i],CH[N-i],EN[N-i],MA[N-i],CO[N-i]);}
cout<
else if(strcmp(u0,"2")==0)
{
cout<<"请输入删除人数:";
int u2,u3,u4,u5;
int k1,k2,k3,k4,k5,k6;char *k7;
cin>>u2;
for(i=0;i
cout<<"请输入第"< cin>>u3;
cout<<"请输入第"< cin>>u4; //查某班级的成绩,是按学号顺序排
u5=find(pupil,u3,u4);
lank(pupil,u3);
k1=pupil[u5].getcl();pupil[u5].putcl(pupil[N-1].getcl());pupil[N-1].putcl(k1);
k7=new char[strlen(pupil[u5].getna())+1];
strcpy(k7,pupil[u5].getna());pupil[u5].putna(pupil[N-1].getna());pupil[N-1].putna(k7);
k2=pupil[u5].getnu();pupil[u5].putnu(pupil[N-1].getnu());pupil[N-1].putnu(k2);
k3=pupil[u5].getch();pupil[u5].putch(pupil[N-1].getch());pupil[N-1].putch(k3);
k4=pupil[u5].geten();pupil[u5].puten(pupil[N-1].geten());pupil[N-1].puten(k4);
k5=pupil[u5].getma();pupil[u5].putma(pupil[N-1].getma());pupil[N-1].putma(k5);
k6=pupil[u5].getco();pupil[u5].putco(pupil[N-1].getco());pupil[N-1].putco(k6);
N=N-1;}}}
cout<<"如果还要添跟删请输入“Y”;";
char u7[2];
cin>>u7;
if(strcmp(u7,"Y")==0||strcmp(u7,"y")==0)continue;
else fun(pupil);break;
}
fun(pupil);
delete[] Name;
delete[] CL;
delete[] NU;
delete[] CH;
delete[] EN;
delete[] MA;
delete[] CO;
}
^^^^^^^^^^^^^^^^^
..........................
好多啊
我的是VB的
不好意思,如果是c语言还能帮上点忙