c++大作业学生信息管理系统源代码(12)
时间:2025-03-10
时间:2025-03-10
c++大作业学生信息管理系统源代码
student *p,*q;
char a[30];
int b;
float c;
p=head;
while (p)
{
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->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->next;
}
p=p->next;
}
}
//◆10
void show(student *head,char *s) //学生成绩信息文件导出功能
{
int n=1;
ofstream outstuf;
outstuf.open(s,ios::out);
if (!outstuf) {cerr<<"file could not be open."<<endl; abort();}
outstuf<<"学号 姓名 班级 语文 数学 英语 总分 均分
while (head)
{
outstuf<<head->num<<" "<<head->name<<'\t'<<head->clas<<'\t'<<" "<<head->chinese<<'\t'
<<head->maths<<'\t'<<head->english<<'\t'<<head->total<<'\t'
<<setprecision(3)<<head->average<<'\t'<<" "<<n<<endl;
n=n+1;
head=head->next; 序号"<<endl;
上一篇:李君如谈建设学习型党组织