};
class othermarks
{
public:
othermarks()
{
cout << "出现错误!!您不该调用此额外科目的默认构造函数!!!" << endl;
}
othermarks(int number)
{
object = new int[number];
//cout << "class新建完成" << number << "个" << endl << "-----------------" << endl;
}
int *object;
};
class student
{
public:
string name;
int englishmark;
int mathmark;
student Next;
othermarks moremarks;
};
class Nodelist
{
public:
Nodelist() :Start(NULL), End(NULL)
{
cout << "已初始化一个空链表" << endl;
}
int getlenth()
{
int num=1;
if (!Start)
return 0;
student *temp = Start;
while (temp!= End)
{
temp = temp->Next;
num++;
}
return num;
}
student* Start;
student* End;
};
int getsallmarks(const student &stp);
int getsallmarks(const student &stp)
{
int sum=0;
if (!whetherLinkMore)
{
sum = stp.englishmark + stp.mathmark;
return sum;
}
else
{
sum += stp.englishmark + stp.mathmark;
for (int i = 0; i < classnumberis; i++)
{
sum+= stp.moremarks->object[i];
}
return sum;
}
}
void Add(Nodelist& p, student stp)//在所输入的student信息之后插入
{
student temp = new student;
if (temp != NULL)
{
cout << "请输入姓名" << endl;
cin >> temp->name;
cout << "请输入英语分数" << endl;
cin >> temp->englishmark;
cout << "请输入数学分数" << endl;
cin >> temp->mathmark;
if (whetherLinkMore)
{
temp->moremarks = new othermarks(classnumberis);
for (int i = 0; i < classnumberis; i++)
{
cout << "请输入额外科目:" << classname[i] << "的分数" << endl;
cin >> temp->moremarks->object[i];
include
include
using namespace std; bool whetherLinkMore = false; int classnumberis = 0; string classname[10]; int option; enum//增加 2删除 3查找 4修改 5按名字插入 6问询链表长度 { 增加 = 1, 删除 =2, 查找 = 3, 修改 =4, 按名字插入 =5, 问询链表长度 =6, 查询全部数据 =7, 退出
}; class othermarks { public: othermarks() { cout << "出现错误!!您不该调用此额外科目的默认构造函数!!!" << endl; } othermarks(int number) { object = new int[number]; //cout << "class新建完成" << number << "个" << endl << "-----------------" << endl; } int *object; }; class student {
public: string name; int englishmark; int mathmark; student Next; othermarks moremarks;
}; class Nodelist { public: Nodelist() :Start(NULL), End(NULL) { cout << "已初始化一个空链表" << endl; } int getlenth() { int num=1; if (!Start) return 0; student *temp = Start; while (temp!= End) { temp = temp->Next; num++; }
}; int getsallmarks(const student &stp); int getsallmarks(const student &stp) { int sum=0; if (!whetherLinkMore) { sum = stp.englishmark + stp.mathmark; return sum; } else { sum += stp.englishmark + stp.mathmark; for (int i = 0; i < classnumberis; i++) {
} void Add(Nodelist& p, student stp)//在所输入的student信息之后插入 { student temp = new student; if (temp != NULL) { cout << "请输入姓名" << endl; cin >> temp->name; cout << "请输入英语分数" << endl; cin >> temp->englishmark; cout << "请输入数学分数" << endl; cin >> temp->mathmark; if (whetherLinkMore) { temp->moremarks = new othermarks(classnumberis); for (int i = 0; i < classnumberis; i++) { cout << "请输入额外科目:" << classname[i] << "的分数" << endl; cin >> temp->moremarks->object[i];
} void Addtofront(Nodelist& p, student stp)//在前面插入 { student temp=p.Start; if (stp != NULL) { if (stp == p.Start) { temp = new student; if (temp != NULL) { cout << "此数据将被添加在表头" << endl; cout << "请输入姓名" << endl; cin >> temp->name; cout << "请输入英语分数" << endl; cin >> temp->englishmark; cout << "请输入数学分数" << endl; cin >> temp->mathmark; if (whetherLinkMore) { temp->moremarks = new othermarks(classnumberis); for (int i = 0; i < classnumberis; i++) { cout << "请输入额外科目:" << classname[i] <<"的分数"<< endl; cin >> temp->moremarks->object[i];
} student search(Nodelist& p, string name) { if (!p.getlenth()) { cout << "链表为空,查询失败!" << endl; return NULL; } student temp = p.Start; if (1 == p.getlenth()) { if (p.Start->name == name) { return temp; } else cout << "未找到目标信息" << endl; return NULL;
} void searchone(Nodelist &p) { cout << "请输入要查找的姓名" << endl; string name; cin >> name; student *temp= search(p, name); if (temp == NULL) { cout << "未找到目标信息" << endl; return; }
} void showstudent(const student &stp) {
} void showstudents(Nodelist &p) { student *temp = p.Start; cout << "姓名\t英语\t数学\t"; if (whetherLinkMore) { for (int i = 0; i < classnumberis; i++) { cout << classname[i] << "\t"; }
} void Add_CanBaseOnName(Nodelist& p) { string name; cout << "请输入要查找的名字" << endl; cin >> name; student * temp; int flag=0; if (p.Start == NULL) { cout << "该链表为空,请直接输入要新增的数据" << endl; Add(p, p.Start); } else { temp = search(p, name); if (temp != NULL) { while (1) {
} void deletNodeList(Nodelist &p, student *stp) { if (0 == p.getlenth()) { cout << "数据为空!" << endl; return; } if (1 == p.getlenth() && stp == p.Start) {
} void deletNodeList(Nodelist &p) { string name; if (0 == p.getlenth()) { cout << "数据为空!" << endl; return; }
} void changestudent(Nodelist &p) { if (0 == p.getlenth()) { cout << "当前数据为空!" << endl; return; } string name; cout << "请输入要替换的学生名字" << endl; cin >> name; student *temp = search(p, name); if (temp == NULL) { cout << "未查询到要求改的目标" << endl; }
}
int main() { cout << "################################################" << endl; cout << "###############学生成绩管理查询系统#############" << endl; cout << "################################################" << endl<<endl; cout << " 支持自定义无限数量的额外科目,以供拓展,默认提供英语,数学的成绩输入 " << endl; cout << "您可以自定义科目的名字,但请注意不能超过10个字符" << endl; cout << "在【按名字插入】功能中,您可以把新的信息录入到任意位置" << endl; cout << "###############以下内容等待实现#############" << endl; cout << "按照指定的科目进行排名并打印。从文件读取、保存等操作" << endl; cout << "排名操作会生成一个新的链表根据需要是否进行替换,或者仅更改输出的顺序 " << endl<<endl<<endl;
}