cout<<"请您输入要查找的班级:";
cin>>NCLASS;
STUDENT::OutputT();
for( p1=SL->next; Findtwo(nterm,NCLASS,&p1,&p2);p1=p1->next)
{p1->Output();}
}
void CLASS::Fail()
{ STUDENT *p1,*p2;
p1=SL->next;
p2=SL;
char nterm[10];
char NCLASS[10];
cout<<"请您输入学期:";
cin>>nterm;
cout<<"请您输入要查找的班级:";
cin>>NCLASS;
STUDENT::OutputT();
for(p1=SL->next;Findtwo(nterm,NCLASS,&p1,&p2);p1=p1->next)
{if(p1->english<60||p1->math<60||p1->c<60||p1->wl<60)
p1->Output();
else
continue;}
}
void CLASS::Printtwo()
{STUDENT *p1,*p2;
p1=SL->next;
p2=SL;
char NCLASS[10];
cout<<"\n** 输出学生信息 **\n";
cout<<"请您输入要查找的班级:";
cin>>NCLASS;
STUDENT::OutputTtwo();
for(p1=SL->next;Findthree(NCLASS,&p1,&p2);p1=p1->next)
{p1->Outputtwo();}
}
void CLASS::Clear()
{STUDENT *p=SL->next;
while(p)
{
SL->next=p->next;
delete p;
p=SL->next;
}
}
void CLASS::ValueS2ToS1(STUDENT &s1,STUDENT &s2)
{
strcpy(s1.num,s2.num);
strcpy(s1.name,s2.name);
strcpy(s1.sex,s2.sex);
strcpy(s1.cname,s2.cname);
s1.english=s2.english;
s1.math=s2.math;
s1.c=s2.c;
s1.wl=s2.wl;
s1.sum=s2.sum;
s1.average=s2.average;
}
void CLASS::AverSort()
{
STUDENT *p1,*p2;
p1=SL->next;
while(p1)
{
p2=p1->next;
while(p2)
{
if(p2->average>p1->average)
{
STUDENT t;
ValueS2ToS1(t,*p1);
ValueS2ToS1(*p1,*p2);
ValueS2ToS1(*p2,t);
}
p2=p2->next;
}
p1=p1->next;
}
Print1();
}
void CLASS::Print1()
{
cout<<"\n** 输出学生信息 **\n";
STUDENT *p=SL->next;
STUDENT::OutputT();
while(p)
{
p->Output();
p=p->next;
}
}
void CLASS::Save()
{
ofstream f("d:student.txt",ios::binary);
STUDENT *p=SL->next;
while(p) //遍历学生链表
{
p->Output(f); //写入文件
p=p->next;
}
f.close();
cout<<"\n** 保存数据完成! **\n";
}
void CLASS::Load()
{
Clear();
ifstream f("student.txt",ios::binary);
STUDENT *p=SL;
STUDENT *p2=new STUDENT;
p2->Input(f);
while(f)
{
p->next=p2;
p=p->next;
p2=new STUDENT;
p2->Input(f);
}
delete p2;
f.close();
}
//main.cpp
#include <fstream.h>
#include <iomanip.h>
#include <string.h>
#include <ctype.h>
#include"stu.h"
void main()
{
char ch;
CLASS c;
do