1、学生信息管理系统源代码:
#include
2、
student *next;
};
//◆1(1)
void createlist(student * & head) //学生成绩文件导入功效(用链表储存)
{
char t[80],num0[30],name0[30],clas0[30];
int chinese0,maths0,english0;
student *s,*p;
ifstream instuf("student-score.txt",ios::in);
if (!instuf) {cerr<<"file could not be open."< 3、stuf.getline(t,80);
while (instuf>>num0>>name0>>clas0>>chinese0>>maths0>>english0)
{
s=new student;
strcpy(s->num,num0);strcpy(s->name,name0);strcpy(s->clas,clas0);
s->chinese=chinese0;s->maths=maths0;s->english=english0;
s->total=s->chinese+s->maths+s->english; s->average=float(s->total)/ 4、3;
if (head==NULL) head=s;
else p->next=s;
p=s;
}
p->next=NULL;
instuf.close();
}
//◆1(2)
void showlist(student *head) //学生成绩信息显示功效(遍历链表)
{
int n=1;
cout<<"学号 姓名 班级 语文 数学 英语 总分 均分 序号 ";
while (head)
{
cout< 5、 6、 *s,*p,*q;
int n,i;
cout<<"请输入需要【插入】学生成绩信息数量: ";
cin>>n;
cout<<"请输入需插入学生成绩信息(每人一行):"< 7、>maths>>s->english;
s->total=s->chinese+s->maths+s->english; s->average=float(s->total)/3;
q->next =s;
q=s;
}
q->next=NULL;
}
//◆3
void shanchu(student * & head) //学生成绩信息删除功效
{
student *p,*q;
char a[30];
int n,i,b=1;
cout<<"请输入需【删除】学生成绩信息数量: ";
cin>>n;
cout<< 8、"请输入需要删除学生学号或姓名:"< 9、me,a)!=0))
{
p=p->next;
}
if (p->next!=NULL)
{
b=0;
q=p->next;
p->next=q->next;
delete q;
q=NULL;
}
}
}
if (b==1) cout<<"无此学号或姓名成绩统计!"< 10、"请输入您要【修改】学生学号或姓名: ";
cin>>a;
while (head)
{
if ((strcmp(head->num,a)==0)||(strcmp(head->name,a)==0))
{
cout<<""< 11、'<<" "
< 12、>english; head->average=float(head->total)/3;
}
head=head->next;
}
if (b==1) cout<<"无此学号或姓名成绩统计!"< 13、 班级 语文 数学 英语 总分 均分"< 14、ision(3)< 15、学 英语 总分 均分"< 16、d=head->next;
}
if (b==1) cout<<"无此班级成绩统计!"< 17、 英语 总分 均分"< 18、
}
head=head->next;
}
if (b==1) cout<<"无此分数段语文成绩统计!"< 19、 班级 语文 数学 英语 总分 均分"< 20、average< 21、 姓名 班级 语文 数学 英语 总分 均分"< 22、sion(3)< 23、l;
cout<<"学号 姓名 班级 语文 数学 英语 总分 均分"< 24、'\t'< 25、>chinese 26、>maths;q->maths=b;
b=p->english;p->english=q->english;q->english=b;
b=p->total;p->total=q->total;q->total=b;
c=p->average;p->average=q->average;q->average=c;
}
q=q->next;
}
p=p->next;
}
}
//◆6(2)
void shuxue(student *head) //按数学成绩从高到低排序功效
{
studen 27、t *p,*q;
char a[30];
int b;
float c;
p=head;
while (p)
{
q=p->next;
while (q)
{
if (p->maths 28、>clas);strcpy(q->clas,a);
b=p->chinese;p->chinese=q->chinese;q->chinese=b;
b=p->maths;p->maths=q->maths;q->maths=b;
b=p->english;p->english=q->english;q->english=b;
b=p->total;p->total=q->total;q->total=b;
c=p->average;p->average=q->average;q->average=c;
}
q=q- 29、>next;
}
p=p->next;
}
}
//◆6(3)
void yingyu(student *head) //按英语成绩从高到低排序功效
{
student *p,*q;
char a[30];
int b;
float c;
p=head;
while (p)
{
q=p->next;
while (q)
{
if (p->english 30、a);
strcpy(a,p->name);strcpy(p->name,q->name);strcpy(q->name,a);
strcpy(a,p->clas);strcpy(p->clas,q->clas);strcpy(q->clas,a);
b=p->chinese;p->chinese=q->chinese;q->chinese=b;
b=p->maths;p->maths=q->maths;q->maths=b;
b=p->english;p->english=q->english;q->english=b;
b=p- 31、>total;p->total=q->total;q->total=b;
c=p->average;p->average=q->average;q->average=c;
}
q=q->next;
}
p=p->next;
}
}
//◆6(4)
void zongfen(student *head) //按总分成绩从高到低排序功效
{
student *p,*q;
char a[30];
int b;
float c;
p=head;
while (p)
{
q=p->next 32、
while (q)
{
if (p->total 33、 b=p->maths;p->maths=q->maths;q->maths=b;
b=p->english;p->english=q->english;q->english=b;
b=p->total;p->total=q->total;q->total=b;
c=p->average;p->average=q->average;q->average=c;
}
q=q->next;
}
p=p->next;
}
}
//◆7
void xuehao(student *head) //按学号从小到 34、大排序功效
{
student *p,*q;
char a[30];
int b;
float c;
p=head;
while (p)
{
q=p->next;
while (q)
{
if (strcmp(p->num,q->num)>0)
{
strcpy(a,p->num);strcpy(p->num,q->num);strcpy(q->num,a);
strcpy(a,p->name);strcpy(p->name,q->name);strcpy(q->name,a);
strcpy(a,p-> 35、clas);strcpy(p->clas,q->clas);strcpy(q->clas,a);
b=p->chinese;p->chinese=q->chinese;q->chinese=b;
b=p->maths;p->maths=q->maths;q->maths=b;
b=p->english;p->english=q->english;q->english=b;
b=p->total;p->total=q->total;q->total=b;
c=p->average;p->average=q->average;q->avera 36、ge=c;
}
q=q->next;
}
p=p->next;
}
}
//◆8
void xingming(student *head) //按姓名首字母排序功效
{
student *p,*q;
char a[30];
int b;
float c;
p=head;
while (p)
{
q=p->next;
while (q)
{
if (strcmp(p->name,q->name)>0)
{
strcpy(a,p->num);strcpy(p->nu 37、m,q->num);strcpy(q->num,a);
strcpy(a,p->name);strcpy(p->name,q->name);strcpy(q->name,a);
strcpy(a,p->clas);strcpy(p->clas,q->clas);strcpy(q->clas,a);
b=p->chinese;p->chinese=q->chinese;q->chinese=b;
b=p->maths;p->maths=q->maths;q->maths=b;
b=p->english;p->english=q->english; 38、q->english=b;
b=p->total;p->total=q->total;q->total=b;
c=p->average;p->average=q->average;q->average=c;
}
q=q->next;
}
p=p->next;
}
}
//◆9
void banji(student *head) //按班级类别排序功效
{
student *p,*q;
char a[30];
int b;
float c;
p=head;
while (p)
{
39、 q=p->next;
while (q)
{
if (strcmp(p->clas,q->clas)>0)
{
strcpy(a,p->num);strcpy(p->num,q->num);strcpy(q->num,a);
strcpy(a,p->name);strcpy(p->name,q->name);strcpy(q->name,a);
strcpy(a,p->clas);strcpy(p->clas,q->clas);strcpy(q->clas,a);
b=p->chinese;p->chinese=q->chine 40、se;q->chinese=b;
b=p->maths;p->maths=q->maths;q->maths=b;
b=p->english;p->english=q->english;q->english=b;
b=p->total;p->total=q->total;q->total=b;
c=p->average;p->average=q->average;q->average=c;
}
q=q->next;
}
p=p->next;
}
}
//◆10
void show(student *hea 41、d,char *s) //学生成绩信息文件导出功效
{
int n=1;
ofstream outstuf;
outstuf.open(s,ios::out);
if (!outstuf) {cerr<<"file could not be open."< 42、>name<<'\t'< 43、r s[30];
cout<<"********************************************************************************";
cout<<"* ★欢迎使用学生成绩管理系统★ *";
cout<<"* 管理员: XXX *";
cout<<"* 请选择您想使用功效: 44、 *";
cout<<"* 功效名 请输入 功效名 请输入 *";
cout<<"* ◆导入学生成绩文件 1 ◆按学号小到大排序 7 *";
cout<<"* ◆插入学生成绩信息 2 ◆按姓名首字母排序 8 *";
cout<<"* ◆删除学生成绩信息 45、 3 ◆按班级类别排序 9 *";
cout<<"* ◆修改学生成绩信息 4 ◆导出学生成绩文件 10 *";
cout<<"* ◆查询学生成绩信息 5 ◆其它功效...... *";
cout<<"* ◆按成绩高到低排序 6 ◆退出管理系统 0 *";
cout<<"**************** 46、";
cout<<"您输入是: ";
cin>>n;
createlist(head);
while (n>0)
{
switch (n)
{
case 1:cout<<"导入需管理学生成绩信息表:"< 47、ist(head);
break;
case 3:shanchu(head);
cout<<"删除后学生成绩信息表:"< 48、 方法 请输入 "< 49、in>>n;
switch (n)
{
case 1:geren(head);
break;
case 2:zongfen(head);
chabanji(head);
break;
case 3:yuwen(head);
chayuwen(head);
break;
case 4:shuxue(head);
chashuxue(h 50、ead);
break;
case 5:yingyu(head);
chayingyu(head);
break;
case 6:zongfen(head);
chazongfen(head);
break;
}
break;
case 6:cout<<"请选择需排序成绩类型:"<






