📄 liststudent.cpp
字号:
#include <iostream>
#include "liststudent.h"
bool Liststudent::insert(const Student & stu)
{
first->next = new Linkstudent(stu, first->next);
if(tail == first)
tail = first->next;
size++;
return true;
}
bool Liststudent::append(const Student &stu)
{
tail->next = new Linkstudent(stu,NULL);
tail = tail->next;
tail->next = NULL;
size++;
return true;
}
void Liststudent::show_all()const
{
cout << "name\tsnumber\tage\tsex\tyuwen\tmath\tenglish\ttotal\taverage"<<endl;
Linkstudent *temp = first->next;
while(temp != NULL)
{
temp->stu.showall();
temp = temp->next;
}
}
bool Liststudent::remove_n(char *n)
{
if(empty()) return false;
Linkstudent *temp = first;
Linkstudent *dele;
while(temp->next != NULL)
{
if(!strcmp(n , temp->next->stu.get_n() ))
{
dele = temp->next;
temp->next = dele->next;
delete dele;
size--;
return true;
}
temp = temp->next;
}
return false;
}
bool Liststudent::remvoe_sn(char *sn)
{
Linkstudent *temp = first;
Linkstudent *dele;
while(temp->next != NULL)
{
if(!strcmp(sn , temp->next->stu.get_sn() ))
{
dele = temp->next;
temp->next = dele->next;
delete dele;
size--;
return true;
}
temp = temp->next;
}
return false;
}
Linkstudent * Liststudent::find_n(char *n)
{
if(empty())
return NULL;
Linkstudent *temp = first->next;
while(temp != NULL)
{
if(!strcmp(n , temp->stu.get_n() ))
return temp;
temp = temp->next;
}
return NULL;
}
Linkstudent * Liststudent::find_sn(char *sn)
{
if(empty())
return NULL;
Linkstudent *temp = first->next;
while(temp != NULL)
{
if(!strcmp(sn , temp->stu.get_sn() ))
return temp;
temp = temp->next;
}
return NULL;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -