结构体
typedef struct student
{
string name; //学生姓名
string num; //准考证号
string ID; //身份证号
int exam_room=-1; //考生考场
int exam_seat=-1; //考生座号
int _num;
double CET4_grades=-1; //四级成绩
double CET6_grades=-1; //六级成绩
double CET4_condition=-1;//四级报名状态
double CET6_condition=-1;//六级报名状态
}ElemType;
/*读取存档*/
void ReadLinkList(LinkList &L)
{
LNode *p = L;
ifstream in("a.txt",ios::in);
if(!in.is_open())
{
cout << "Error opening file"; exit (1); }
while (!in.eof()){
LNode *s = new LNode;
in>>s->data.name>>s->data.num>>s->data.ID
>>s->data.exam_room>>s->data.exam_seat
>>s->data.CET4_grades>>s->data.CET6_grades
>>s->data.CET4_condition>>s->data.CET6_condition;
if(s->data.CET4_condition==-1&&s->data.CET6_condition==-1){
delete s; //若读取的数据为空,则删除s结点
}
else{
s->next = NULL;
p->next = s;
p = s;
}
}
}
/*存档链表*/
void SaveLinkList(LinkList & L)
{
ofstream out("a.txt",ios::out);
LNode* p;
p=L->next;
while(p){
out<<p->data.name<<" "<<p->data.num<<" "<<p->data.ID<<" "
<<p->data.exam_room<<" "<<p->data.exam_seat<<" "
<<p->data.CET4_grades<<" "<<p->data.CET6_grades<<" "
<<p->data.CET4_condition<<" "<<p->data.CET6_condition<<"\n";
p=p->next;
}
out.close();
}