数据结构实验--实验一线性数据结构的实现与应用


实验目的

  1. 掌握线性表的单链表实现与静态链表实现。
  2. 掌握线性表的应用:运动会信息管理系统。

实验要求、内容

  1. 基于单链表实现线性表 List1 的典型操作(判空、判满、求表长、插入、删除、查找、修改、遍历、置空、普 通构造、拷贝构造、赋值运算符重载、析构),编写简单程序使用该线性表,测试和调试程序。
  2. 基于静态链表实现线性表 List2 的典型操作(判空、判满、求表长、插入、删除、查找、修改、遍历、置空、 普通构造),编写简单程序使用该线性表,测试和调试程序。
  3. 基于线性表 List1、线性表 List2 实现线性表的应用:运动会信息管理,测试和调试程序。

实验设备

计算机、Windows 操作系统、C++语言集成开发环境。

实验指导

  1. 基于单链表实现线性表 List1 的典型操作(判空、判满、求表长、插入、删除、查找、修改、遍历、置空、普 通构造、拷贝构造、赋值运算符重载、析构),编写简单程序使用该线性表,测试和调试程序。
  2. 基于静态链表实现线性表 List2 的典型操作(判空、判满、求表长、插入、删除、查找、修改、遍历、置空、普通 构造),编写简单程序使用该线性表,测试和调试程序。
  3. 基于线性表 List1、线性表 List2 实现线性表的应用:运动会信息管理,测试和调试程序。这一步,主要是编写运动会信息管理系统,要求如下。

使用 C++语言,设计数据类型与数据存储结构,编写一个命令行菜单驱动的运动会信息管理系统,实现运动会项 目(使用 List1)增加、删除、修改、查询等功能;运动员学生(使用 List2)报名、撤销报名、参赛前检录、参赛成绩 录入、查询、修改等功能;学院分数统计与排序(分别按男子团体、女子团体、男女混合团体前 6 名)等功能。
运动会项目增加。增加时需要以下信息:项目名称、编号(假设为 6 位数字)、参与该项目的运动员性别、比赛 日期、比赛时间、比赛人数。
项目删除。找到该项目信息后,将其删除。
项目信息修改。找到该项目信息后,将其信息修改。
项目信息查询。找到该项目信息后,将其信息显示。
运动员学生报名。报名时需要以下信息:学生姓名、学号(假设为 10 位数字)、性别、所属学院、参赛项目编号 (6 位数字)、是否检录、参赛成绩、排名、分数(注:第一名 3 分、第二名 2 分、第三名 1 分)。
撤销报名。找到该项报名信息后,将其删除。
参赛前检录。找到该项报名信息后,将是否检录状态从未检录置为已检录。
参赛成绩录入。某项比赛完成后,录入参加比赛同学的成绩、排名,并自动获得分数。 运动员信息查询。
找到该运动员信息后,将其信息显示。 运动员信息修改。找到该运动员信息后,将其信息修改。 学院分数统计与排序。
分别按男子团体、女子团体、男女混合团体对学院进行排名,各取前 6 名.
永久性存储。运动会所有项目以及学生参赛信息能够在程序结束时存至文件,程序运行时从文件读入。

UTILITY_H

#ifndef UNTITLED_UTILITY_H
#define UNTITLED_UTILITY_H
#include <iostream>
enum Error_code { success, fail, range_error1, underflow,
        overflow, fatal, not_present, duplicate_error,
        entry_inserted, entry_found, internal_error };
#endif //UNTITLED_UTILITY_H

List1.h

#ifndef UNTITLED_LIST1_H
#define UNTITLED_LIST1_H
#include"UTILITY.h"
template <class Node_entry> 
struct Node//节点
{
    Node_entry entry;//数据域
    Node<Node_entry> *next;//指针,指向一个节点
    Node()//构造函数
    {
        next = NULL;
    }
    explicit Node(Node_entry data, Node<Node_entry> *link_next = NULL)//构造函数
    {
        entry = data;
        next = link_next;
    }
};
template <class List_entry>
class List1 {
public:
    List1();//构造函数
    int size() const;//返回链表的长度
    bool full() const;//判断链表是否满
    bool empty() const;//判断链表是否空
    void clear();//清空链表
    void traverse(void (*visit)(List_entry &));//遍历链表
    Error_code retrieve(int position, List_entry &x) const;//返回第position个节点的值
    Error_code replace(int position, const List_entry &x);//替换第position个节点的值
    Error_code remove(int position, List_entry &x);//删除第position个节点的值
    Error_code insert(int position, const List_entry &x);//插入第position个节点的值
    ~List1();//析构函数
    List1(const List1<List_entry> &copy);//复制构造函数
    void operator =(const List1<List_entry> &copy);//赋值运算符
protected:
//Data members for the linked list implementation follow:
    int count;//记录链表的长度
    Node<List_entry> *head;//指向链表的头节点
//The auxiliary function to locate list positions follows:
    Node<List_entry> * set_position(int position) const;//返回第position个节点的指针
};
#endif //UNTITLED_LIST1_H

List1.cpp

#include"List1.h"
template <class List_entry>
Node<List_entry> * List1<List_entry>::set_position(int position) const//返回position位置上的指针
{
    if (position < 0 || position >= count)//如果position位置不在范围内,则返回空指针
        return NULL;
    Node<List_entry> *p = head;
    for (int i = 0; i < position; i++) 
    {//从头节点索引开始,按照position位置移动到相应的节点索引
        p = p->next;
    }
    return p;
}

template <class List_entry>
List1<List_entry>::List1()//构造函数
{
    count = 0;
    head = NULL;
}

template <class List_entry>
int List1<List_entry>::size() const//返回链表的大小
{
    return count;
}

template <class List_entry>
bool List1<List_entry>::full() const//判断链表是否满
{
    return false;
}

template <class List_entry>
bool List1<List_entry>::empty() const//判断链表是否空
{
    return count == 0;
}

template <class List_entry>
void List1<List_entry>::clear()//清空链表
{
    Node<List_entry> *p,*q;
    for(p=head;p!=NULL;p=q)
    {//从头节点开始,删除所有节点
        q=p->next;
        delete p;
    }
    count=0;
    head=NULL;
}

template <class List_entry>
void List1<List_entry>::traverse(void (*visit)(List_entry &))//遍历链表
{
    if(empty()) {
        printf("List is empty\n");
        return;
    }
    Node<List_entry> *p;
    for(p=head;p!=NULL;p=p->next)
    {
        (*visit)(p->entry);
    }
}

template <class List_entry>//返回第position个节点的值
Error_code List1<List_entry>::retrieve(int position, List_entry &x) const
{
    if(position<0||position>=count)
    {
        return range_error1;
    }
    Node<List_entry> *p=set_position(position);//获取position位置上的节点指针
    x=p->entry;//获取节点的值
    return success;
}

template <class List_entry>//替换
Error_code List1<List_entry>::replace(int position, const List_entry &x)
{
    if(position<0||position>=count){
        return range_error1;
    }
    Node<List_entry> *p=set_position(position);
    p->entry=x;
    return success;
}

template <class List_entry>//删除
Error_code List1<List_entry>::remove(int position, List_entry &x)
{
    if(count==0)
    {//如果链表为空,则返回fail
        cout<<"List is empty"<<endl;
        return fail;
    }
    if(position<0||position>=count)
    {//如果position位置不在范围内,则返回range_error1
        return range_error1;
    }
    Node<List_entry> *p=set_position(position);
    x=p->entry;
    if(position==0){
        head=p->next;//如果删除的是头节点,则将头节点指针指向下一个节点
    }else{
        set_position(position-1)->next=p->next;//设置前一个节点的next指针指向后一个节点
    }
    delete p;
    count--;
    return success;
}

template <class List_entry>//插入
Error_code List1<List_entry>::insert(int position, const List_entry &x)
{
    if(position<0||position>count){//如果position位置不在范围内,则返回range_error1
        return range_error1;
    }
    Node<List_entry> *new_node,*previous,*following;//新指针,前一个节点,原position上的指针
    if(position>0){//如果position位置不是头节点,则获取前一个节点指针
        previous=set_position(position-1);//获取position位置上的前一个节点指针
        following=previous->next;//获取原position上的指针
    }else following=head;//如果position位置是头节点,则获取头节点指针
    new_node=new Node<List_entry>(x,following);//创建新节点
    if(new_node==NULL){//如果创建失败,则返回溢出错误
        return overflow;
    }
    if(position==0){//如果position位置是头节点,则将头节点指针指向新节点
        head=new_node;
    }else previous->next=new_node;//如果position位置不是头节点,则设置前一个节点的next指针指向新节点
    count++;//计数器加1
    return success;
}


template <class List_entry>
List1<List_entry>::~List1()//析构函数
{
    clear();
}

template <class List_entry>//拷贝构造函数
List1<List_entry>::List1(const List1<List_entry> &copy)
{
    Node<List_entry> *p,*q;//p为拷贝源的节点,q为拷贝目-及当前对象的的节点
    for(p=copy.head,q=head;p!=NULL;p=p->next,q=q->next){
        q->entry=p->entry;//拷贝节点的值
        q->next=new Node<List_entry>(p->next);//以新节点的形式拷贝下一个节点
    }
    count=copy.count;//拷贝计数器的值
}

template <class List_entry>//赋值运算符
void List1<List_entry>::operator =(const List1<List_entry> &copy)
{
    Node<List_entry> *p,*q;
    for(p=copy.head,q=head;p!=NULL;p=p->next,q=q->next){
        q->entry=p->entry;
        q->next=new Node<List_entry>(p->next);
    }
    count=copy.count;
}

List2.h

#ifndef UNTITLED_LIST2_H
#define UNTITLED_LIST2_H

#include"UTILITY.h"
typedef int Index;//节点索引
const int max_list = 1000; // value for testing purposes


template <class List_entry>
class Node2//list2的节点
{
public:
    List_entry entry;//节点内容
    Index next;//指向下一个节点的索引
};

template <class List_entry>
class List2 {
public:
//Methods of the list ADT
    List2();//构造函数
    int size() const;//返回链表中的节点数
    bool full() const;//判断链表是否已满
    bool empty() const;//判断链表是否为空
    void clear();//清空链表
    void traverse(void (*visit)(List_entry &));//遍历链表
    Error_code retrieve(int position, List_entry &x) const;//返回第position个节点的值
    Error_code replace(int position, const List_entry &x);//替换第position个节点的值
    Error_code remove(int position, List_entry &x);//删除第position个节点的值
    Error_code insert(int position, const List_entry &x);//插入第position个节点的值
protected:
//Data members
    Node2<List_entry> workspace[max_list];//节点空间
    Index available, last_used, head;//使用过的空闲数组索引,最后使用过的数组索引,链表头节点索引
    int count;//记录链表中的节点数
//Auxiliary member functions
    Index new_node();//分配一个新的节点索引
    void delete_node(Index n);//释放一个节点索引
    int current_position(Index n) const;//返回节点索引n在链表中的位置
    Index set_position(int position) const;//设置当前节点索引
};
#endif //UNTITLED_LIST2_H

List2.cpp

#include"List2.h"
template <class List_entry> List2<List_entry>::List2()//构造函数
{
    count = 0;
    available=-1;
    last_used=-1;
    head=-1;
}

template <class List_entry> Index List2<List_entry>::new_node()//分配一个新的节点索引
{
    Index result;//新的节点索引
    if(available!=-1)
    {//如果有空闲的使用过的节点,则直接使用
        result=available;
        available=workspace[available].next;
    }else if(last_used<max_list-1)
    {//如果没有空闲的使用过的节点,但是还有空闲的没用过节点空间,则直接使用
        result=++last_used;
    }else return -1;
    workspace[result].next=-1;//将新的节点索引的下一个节点索引设置为-1
    return result;
}

template <class List_entry> void List2<List_entry>::delete_node(Index n)
{
    Index p;
    if(n==head)
    {//如果要删除的节点是头节点,则将头节点索引设置为下一个节点索引
        head=workspace[n].next;
    }else{//如果要删除的节点不是头节点,则将前一个节点的下一个节点索引设置为下一个节点索引
        p=set_position(current_position(n)-1);
        workspace[p].next=workspace[n].next;//将前一个节点的下一个节点索引设置为下一个节点索引
    }
    workspace[n].next=available;
    available=n;
}

template <class List_entry> 
int List2<List_entry>::current_position(Index n) const//返回节点索引的位置
{
    Index p=head;//节点索引,初始值为头节点索引
    int position=0;//节点索引的位置,初始值为0
    while(p!=-1&&p!=n)
    {//如果节点索引不是-1,且不是要查找的节点索引,则将节点索引移动到下一个节点索引
        p=workspace[p].next;//节点索引移动到下一个节点索引
        position++;//节点索引的位置加1
    }
    if(p==-1) return -1;//如果节点索引是-1,则返回-1  表示没有找到
    else return position;//如果节点索引不是-1,则返回节点索引的位置
}

template <class List_entry> 
Index List2<List_entry>::set_position(int position) const//返回position位置上的节点索引
{
    Index result=head;//节点索引,初始值为头节点索引
    if(position<0||position>=count){
        return -1;//如果节点索引的位置小于0或者大于等于节点数,则返回-1
    }
    for(int i=0;i<position;i++){
        result=workspace[result].next;//节点索引移动到下一个节点索引
    }
    return result;
}

template <class List_entry> int List2<List_entry>::size() const//返回链表中的节点数
{
    return count;
}

template <class List_entry> bool List2<List_entry>::full() const//返回链表是否满
{
    return last_used==max_list-1&&available==-1;//如果最后一个使用过的节点索引等于最大节点索引,且没有空闲的节点空间,则返回true
}

template <class List_entry> bool List2<List_entry>::empty() const//返回是否为空
{
    return count==0;//如果节点数为0,则返回true
}

template <class List_entry> void List2<List_entry>::clear()//清空
{
    Index p,q;
    for(p=head;p!=-1;p=q)
    {
        q=workspace[p].next;//将节点索引移动到下一个节点索引
        delete_node(p);//删除节点
    }
    count=0;
    head=-1;
}

template <class List_entry> 
void List2<List_entry>::traverse(void (*visit)(List_entry &))//返回第position个节点的值
{
    if(empty())
    {
        printf("List is empty\n");
        return;
    }
    Index p;//节点索引
    for(p=head;p!=-1;p=workspace[p].next){
        (*visit)(workspace[p].entry);
    }
}

template <class List_entry> 
Error_code List2<List_entry>::retrieve(int position, List_entry &x) const//返回指定位置的节点的值
{
    if(position<0||position>=count)
    {
        return range_error1;
    }
    Index p=set_position(position);//设置节点索引
    x=workspace[p].entry;//节点内容赋给x
    return success;
}

template <class List_entry> 
Error_code List2<List_entry>::replace(int position, const List_entry &x)//替换指定位置的节点的值
{
    if(position<0||position>=count)
    {
        return range_error1;
    }
    Index p=set_position(position);
    workspace[p].entry=x;//设置节点内容
    return success;
}

template <class List_entry>
Error_code List2<List_entry>::remove(int position, List_entry &x)//删除指定位置的节点
{
    if(empty())//如果链表为空,则返回错误信息
    {
        return underflow;
    }
    if(position<0||position>=count){
        return range_error1;
    }
    Index p=set_position(position);
    x=workspace[p].entry;
    delete_node(p);//删除节点
    count--;//节点数减1
    return success;
}

template <class List_entry>
Error_code List2<List_entry>::insert(int position, const List_entry &x)//插入指定位置的节点
{
    if(full())//如果链表满,则返回错误信息
    {
        return overflow;
    }
    if(position<0||position>count)
    {
        return range_error1;
    }
    Index p,q,new_index;//节点索引,节点索引,新节点索引
    if(position>0)
    {//如果插入位置不是头节点
        p=set_position(position-1);//p为上一个节点索引
        q=workspace[p].next;//q为当前position位置上的节点索引
    }else{//如果插入位置是头节点,q为头节点索引
        q=head;
    }
    new_index=new_node();//新建节点
    if(new_index==-1)
    {//如果新建节点失败
        return overflow;//返回溢出错误
    }
    workspace[new_index].entry=x;
    workspace[new_index].next=q;//新节点的下一个节点索引为之前position位置上的节点索引
    if(position==0){
        head=new_index;//如果插入位置是头节点,则将新节点索引设置为头节点索引
    }else{
        workspace[p].next=new_index;//如果插入位置不是头节点,则将上一个节点索引的下一个节点索引设置为新节点索引
    }
    count++;//节点数加1
    return success;
}

Item.h

#ifndef ITEM_H
#define ITEM_H

#include <cstring>
#include"List1.h"
#include "List1.cpp"
using namespace std;

struct data_new//比赛日期
{
    int year;
    int month;
    int day;
};
struct time_new//比赛时间
{
    int hour;
    int minute;
    int second;
};

struct item
{

    char name[20];//项目名称
    char id[7];//编号
    char sex[10];//参与该项目的运动员性别(a男,b女,c男女混合)
    data_new item_data;//比赛日期
    time_new item_time;//比赛时间
    int number_people;//比赛人数
};

List1<item>item_list1;

//创建菜单
int menu_item_select()
{
    cout<<"\n                    运动会项目管理系统"<<endl;
    cout<<"==========================================================="<<endl;
    cout<<"                    1.新建项目"<<endl;
    cout<<"                    2.添加项目"<<endl;
    cout<<"                    3.查询项目"<<endl;
    cout<<"                    4.修改项目"<<endl;
    cout<<"                    5.删除项目"<<endl;
    cout<<"                    6.显示所有项目"<<endl;
    cout<<"                    0.退出"<<endl;
    cout<<"==========================================================="<<endl;
    cout<<"                    请输入您的选择(0-6):";
    while(1){
        char c[10];//输入的字符,防止输入非数字和超过范围的数字
        cin>>c;
        int sn=c[0]-'0';//将字符转换为数字
        if(sn>=0&&sn<=6&&c[1]=='\0')//判断输入是否在0-6之间
        {
            return sn;
        }else cout<<"\n\t输入错误,重选0-6:";
    }
}

//查找节点位置
int Item_find(item &item_find)
{
    int i=0;//记录节点位置
    item temp;//临时变量
    while(i<item_list1.size()){
        item_list1.retrieve(i,temp);//取出节点
        if(strcmp(item_find.id,temp.id)==0)
        {//判断是否找到
            return i;
        }
        i++;
    }
    //没有找到,返回-1
    return -1;
}

//查找节点位置,函数重载
int Item_find(char *id)
{
    int i=0;
    item temp;
    while(i<item_list1.size()){
        item_list1.retrieve(i,temp);
        if(strcmp(id,temp.id)==0){
            return i;
        }
        i++;
    }
    return -1;
}


//新建项目
void CreateList_item(){
    char flag='y'; //结束标志置
    item temp{};
    item_list1.clear();//新建项目前先   清空链表
    while(flag=='y'||flag=='Y')//结束标志置为y时,继续新建项目
    {
        cout<<"\t请顺序输入:\n";
        cout<<"\t\t项目名称(20)\n\t\t编号(6)\n\t\t参与该项目的运动员性别(a男,b女,c男女混合)\n ";
        cout<< "\t\t比赛日期(年 月 日)\n\t\t比赛时间(时 分 秒)\n\t\t比赛人数\n";
        cout<<"\t-----------------------------------------------\n";
        cin>>temp.name>>temp.id>>temp.sex
            >>temp.item_data.year>>temp.item_data.month>>temp.item_data.day
            >>temp.item_time.hour>>temp.item_time.minute>>temp.item_time.second
            >>temp.number_people;
        if(temp.sex[0]!='a'&&temp.sex[0]!='b'&&temp.sex[0]!='c'||temp.sex[1]!='\0')
        {
            cout<<"性别错误,请重新输入!" << endl;
            continue;
        }
        if(Item_find(temp)!=-1){
            cout << "该项目已存在,请重新输入!" << endl;
            continue;
        }
        item_list1.insert(item_list1.size(),temp);
        cout<<"继续输入吗?(y/n):";
        cin>>flag;//继续输入标志
        cout<<endl;
    }
    cout<<"\n\t创建成功!"<<endl;
    cout<<"--------------------------------------------------------------------------------------\n";
}

//添加项目
void InsertNode_item(){
    item temp{};
    int pos;
    cout<<"请输入你要插入的位置:";
    while(1){
        cin>>pos;
        if(pos<0||pos>item_list1.size()){
            cout<<"\n\t输入错误,重选0-"<<item_list1.size()-1<<":";
        }else break;
    }
    cout<<"--------------------------------------------------------------------------------------\n";
    cout<<"\t\t项目名称(20)\n\t\t编号(6)\n\t\t参与该项目的运动员性别(a男,b女,c男女混合)\n ";
        cout<< "\t\t比赛日期(年 月 日)\n\t\t比赛时间(时 分 秒)\n\t\t比赛人数\n";
        cout<<"\t-----------------------------------------------\n";
    cin>>temp.name>>temp.id>>temp.sex
            >>temp.item_data.year>>temp.item_data.month>>temp.item_data.day
            >>temp.item_time.hour>>temp.item_time.minute>>temp.item_time.second
            >>temp.number_people;
    cout<<"--------------------------------------------------------------------------------------\n";
    if(Item_find(temp)!=-1 )
    {
        cout << "该项目已存在!" << endl;
        return;
    }
    if(temp.sex[0]!='a'&&temp.sex[0]!='b'&&temp.sex[0]!='c'||temp.sex[1]!='\0')
    {
        cout<<"性别错误,请重新输入!" << endl;
        return;
    }
    item_list1.insert(pos,temp);
}


//查询项目
void ListFind_item(){
    item temp{};
    int pos;
    printf("请输入要查找项目的编号:");
    cin>>temp.id;
    pos=Item_find(temp);
    if(pos==-1) {
        cout << "查找失败!" << endl;
    }else 
    {
        item_list1.retrieve(pos,temp);
        cout<<"-----------------------------------------------------------------------------------\n";
        printf("项目名称:%s\n编号:%s\n",temp.name,temp.id);
        switch (temp.sex[0]) 
        {
            case 'a':printf("参与该项目的运动员性别:男");break;
            case 'b':printf("参与该项目的运动员性别:女");break;
            case 'c':printf("参与该项目的运动员性别:男女混合");break;
        }
        printf("\n比赛日期:%d年%d月%d日\n",temp.item_data.year,temp.item_data.month,temp.item_data.day);
        printf("比赛时间:%d时%d分%d秒\n",temp.item_time.hour,temp.item_time.minute,temp.item_time.second);
        printf("比赛人数:%d\n",temp.number_people);
        cout<<"------------------------------------------------------------------------------------\n";
    }
}


//修改项目
void ChangeNode_item()
{
    item temp{};
    int pos;
    printf("请输入要修改项目的编号:");
    cin>>temp.id;
    pos=Item_find(temp);
    if(pos==-1) {
        cout << "没有查找要修改项目!" << endl;
    }else{
        item_list1.retrieve(pos,temp);
        cout << "----------------------------------------原来的项目----------------------------------------\n";
        printf("项目名称:%s\n编号:%s\n",temp.name,temp.id);
        switch (temp.sex[0]) {
            case 'a':printf("参与该项目的运动员性别:男");break;
            case 'b':printf("参与该项目的运动员性别:女");break;
            case 'c':printf("参与该项目的运动员性别:男女混合");break;
        }
        printf("\n比赛日期:%d年%d月%d日\n",temp.item_data.year,temp.item_data.month,temp.item_data.day);
        printf("比赛时间:%d时%d分%d秒\n",temp.item_time.hour,temp.item_time.minute,temp.item_time.second);
        printf("比赛人数:%d\n",temp.number_people);
        cout<<"-----------------------------------------------------------------------------------\n";
        cout<<"----------------------------------新的项目-------------------------------------------\n";
        cout<<"\t请顺序输入:\n";
        cout<<"\t\t项目名称(20)\n\t\t编号(6)\n\t\t参与该项目的运动员性别(a男,b女,c男女混合)\n ";
        cout<< "\t\t比赛日期(年 月 日)\n\t\t比赛时间(时 分 秒)\n\t\t比赛人数\n";
        cout<<"\t-----------------------------------------------\n";
        cin>>temp.name>>temp.id>>temp.sex[0]
                >>temp.item_data.year>>temp.item_data.month>>temp.item_data.day
                >>temp.item_time.hour>>temp.item_time.minute>>temp.item_time.second
                >>temp.number_people;
        int pos1=Item_find(temp);
        if(pos1!=-1&&pos1!=pos)
        {
            cout << "该项目已存在!" << endl;
            return;
        }
        if(temp.sex[0]!='a'&&temp.sex[0]!='b'&&temp.sex[0]!='c'||temp.sex[1]!='\0')
        {
            cout<<"性别错误,请重新输入!" << endl;
            return;
        }
        item_list1.replace(pos,temp);
        cout<<"------------------------------------------------------------------------------------\n";
    }
}


//删除项目
void DeleteNode_item()
{
    item temp{};
    int pos;
    printf("请输入要删除项目的编号:");
    cin>>temp.id;
    pos=Item_find(temp);
    if(pos==-1) {
        cout << "没有查找要删除项目!" << endl;
    }else {
        item_list1.remove(pos, temp);
        cout << "----------------------------------------要删除的项目----------------------------------------\n";
        printf("项目名称:%s\n编号:%s\n", temp.name, temp.id);
        switch (temp.sex[0]) {
            case 'a':
                printf("参与该项目的运动员性别:男");
                break;
            case 'b':
                printf("参与该项目的运动员性别:女");
                break;
            case 'c':
                printf("参与该项目的运动员性别:男女混合");
                break;
        }
        printf("\n比赛日期:%d年%d月%d日\n", temp.item_data.year, temp.item_data.month, temp.item_data.day);
        printf("比赛时间:%d时%d分%d秒\n", temp.item_time.hour, temp.item_time.minute, temp.item_time.second);
        printf("比赛人数:%d\n",temp.number_people);
        cout << "-------------------------------------------已删除!----------------------------------------\n";
    }
}

//打印项目
void print_item(item& temp) 
{
    printf("--------------------------------------编号:%s--------------------------------------\n",temp.id);
    printf("项目名称:%s\n编号:%s\n", temp.name, temp.id);
    switch (temp.sex[0]) {
        case 'a':
            printf("参与该项目的运动员性别:男");
            break;
        case 'b':
            printf("参与该项目的运动员性别:女");
            break;
        case 'c':
            printf("参与该项目的运动员性别:男女混合");
            break;
    }
    printf("\n比赛日期:%d年%d月%d日\n", temp.item_data.year, temp.item_data.month, temp.item_data.day);
    printf("比赛时间:%d时%d分%d秒\n", temp.item_time.hour, temp.item_time.minute, temp.item_time.second);
    printf("比赛人数:%d\n",temp.number_people);
    cout << "-----------------------------------------------------------------------------------\n\n";
}

//打印项目列表
void PrintList_item(){
    cout<<"----------------------------------共有"<<item_list1.size()<<"个项目-------------------------------------------\n";
    cout<<"\t项目如下:\n";
    item_list1.traverse(print_item);//用函数指针实现遍历
}
#endif //ITEM_H

Student.h

#ifndef STUDENT_H
#define STUDENT_H

#include <cstring>
#include"List2.h"
#include "List2.cpp"
#include "Item.h"
using namespace std;

struct student
{
    char name[21];//姓名
    char id[11];  //学号
    char sex[10];//性别
    int college_num;//学院编号
    char college[21]; //学院
    char item_id[7];  //项目
    char check='n';//是否检录
    int rank=0;//排名
    int fraction=0;//分数
    double score=0;//成绩
};

List2<student> stu_list2;

//创建菜单
int menu_stu_select()
{
    cout<<"\n                 运动员管理系统"<<endl;
    cout<<"==========================================================="<<endl;
    cout<<"                 1.新建报名信息"<<endl;
    cout<<"                 2.插入报名信息"<<endl;
    cout<<"                 3.查询报名信息"<<endl;
    cout<<"                 4.修改报名信息"<<endl;
    cout<<"                 5.撤销报名信息"<<endl;
    cout<<"                 6.参赛前检录"<<endl;
    cout<<"                 7.参赛成绩录入"<<endl;
    cout<<"                 8.显示所有报名信息"<<endl;
    cout<<"                 0.退出运动员管理系统"<<endl;
    cout<<"==========================================================="<<endl;
    cout<<"                 请输入您的选择(0-8):";
    while(1){
        char c[10];
        cin>>c;
        int sn=c[0]-'0';
        if(sn>=0&&sn<=8&&c[1]=='\0')//判断输入是否在0-8之间
        {
            return sn;
        }
        else cout<<"\n\t输入错误,重选0-8:";
    }
}

//查找节点位置
int  Stu_find(student &stu_find)
{
    int i=0;
    student temp;
    while(i<stu_list2.size())
    {
        stu_list2.retrieve(i,temp);
        if(strcmp(stu_find.id,temp.id)==0){
            return i;
        }
        i++;
    }
    return -1;
}

//学院选择 
void Stu_college_select(student &stu_college)
{
    cout<<"\n\t学院:"<<endl;
    cout<<"\t1.计算机学院"<<endl;
    cout<<"\t2.电子学院"<<endl;
    cout<<"\t3.自动化学院"<<endl;
    cout<<"\t4.计算机科学与技术学院"<<endl;
    cout<<"\t5.网络工程学院"<<endl;
    cout<<"\t6.软件学院"<<endl;
    cout<<"\t7.网络安全学院"<<endl;
    cout<<"\t8.软件工程学院"<<endl;
    cout<<"\t9.网络空间安全学院"<<endl;
    cout<<"--------------------------------------------------------------------------------\n";
    while(1)
    {//输入学院编号
        cout<<"\n\t请选择学院:";
        char c[10];
        cin>>c;
        int sn=c[0]-'0';
        if(sn>=1&&sn<=9&&c[1]=='\0')//判断输入是否为数字且是否在1-9之间
        {
            stu_college.college_num=sn;//赋值学院编号
            switch(sn)
            {//赋值学院名称
                case 1:
                    strcpy(stu_college.college,"计算机学院");
                    break;
                case 2:
                    strcpy(stu_college.college,"电子学院");
                    break;
                case 3:
                    strcpy(stu_college.college,"自动化学院");
                    break;
                case 4:
                    strcpy(stu_college.college,"计算机科学与技术学院");
                    break;
                case 5:
                    strcpy(stu_college.college,"网络工程学院");
                    break;
                case 6:
                    strcpy(stu_college.college,"软件学院");
                    break;
                case 7:
                    strcpy(stu_college.college,"网络安全学院");
                    break;
                case 8:
                    strcpy(stu_college.college,"软件工程学院");
                    break;
                case 9:
                    strcpy(stu_college.college,"网络空间安全学院");
                    break;
            }
            return;
        }
        else cout<<"\n\t输入错误,重选1-9:";
    }
}

//学院判断
string Stu_college_find(int n)
{
    string college;
    switch(n)
    {
        case 1:
            college="计算机学院";
            break;
        case 2:
            college="电子学院";
            break;
        case 3:
            college="自动化学院";
            break;
        case 4:
            college="计算机科学与技术学院";
            break;
        case 5:
            college="网络工程学院";
            break;
        case 6:
            college="软件学院";
            break;
        case 7:
            college="网络安全学院";
            break;
        case 8:
            college="软件工程学院";
            break;
        case 9:
            college="网络空间安全学院";
            break;
    }
    return college;
}

//新建学生信息
void CreateList_stu(){
    char flag='y'; //结束标志置
    student temp{};
    stu_list2.clear();
    while(flag=='y'||flag=='Y'&&stu_list2.size()<=max_list){
        if(stu_list2.full()){
            cout<<"\n\t列表已满!"<<endl;
            return;
        }
        cout<<"\t请顺序输入:"<<endl;
        cout<<"\t\t姓名(20)\n\t\t学号(10)\n\t\t性别(a,b)\n\t\t参赛项目编号(6)"<<endl;
        cout<<"--------------------------------------------------------------------------------\n";
        cin>>temp.name>>temp.id>>temp.sex>>temp.item_id;
        if(Stu_find(temp)!=-1 )
        {//判断运动员是否存在
            cout << "该运动员已存在,请重新输入!\n" << endl;
            continue;
        }
        if(Item_find(temp.item_id)==-1)
        {//判断项目是否存在
            cout << "参赛项目不存在,请重新输入!\n" << endl;
            continue;
        }
        if(temp.sex[0]!='a'&&temp.sex[0]!='b'||temp.sex[1]!='\0')
        {//判断性别输入是否错误
            cout<<"性别错误,请重新输入!" << endl;
            continue;
        }
        Stu_college_select(temp);   
        stu_list2.insert(stu_list2.size(),temp);
        cout<<"继续输入吗?(y/n):";
        cin>>flag;
        cout<<endl;
    }
    cout<<"\n\t创建成功!"<<endl;
}

//插入学生信息
void InsertNode_stu(){
    if(stu_list2.full()){
        cout<<"\n\t列表已满!"<<endl;
        return;
    }
    int pos;
    student temp{};
    cout<<"请输入位置:";
    while(1){
        cin>>pos;
        if(pos<1||pos>stu_list2.size()){
            cout<<"\n\t输入错误,重选1-"<<stu_list2.size()<<":";
        }else break;
    }
    cout<<"-------------------------------------------------------------------------------------\n";
    cout<<"\t请顺序输入:"<<endl;
    cout<<"\t\t姓名(20)\n\t\t学号(10)\n\t\t性别(a,b)\n\t\t参赛项目编号(6)"<<endl;
    cout<<"--------------------------------------------------------------------------------\n";
    cin>>temp.name>>temp.id>>temp.sex>>temp.item_id;
    if(Stu_find(temp)!=-1 ){
        cout << "该运动员已存在!\n" << endl;
        return;
    }
    if(temp.sex[0]!='a'&&temp.sex[0]!='b'||temp.sex[1]!='\0')
    {
        cout<<"性别错误,请重新输入!" << endl;
        return;
    }
    Stu_college_select(temp);
    stu_list2.insert(pos,temp);
    cout<<"\t插入成功!\n"<<endl;
}


//查询学生信息
void ListFind_stu(){
    student temp{};
    int pos;
    printf("请输入要查找的学号:");
    cin>>temp.id;
    pos= Stu_find(temp);
    if(pos==-1) {
        cout << "查找失败!" << endl;
    }else {
        stu_list2.retrieve(pos,temp);
        cout<<"----------------------------------你要查找的远动员--------------------------------------\n";
        printf("姓名:%s\n学号:%s\n",temp.name,temp.id);
        switch (temp.sex[0]) {
            case 'a':printf("性别:男\n");break;
            case 'b':printf("性别:女\n");break;
        }
        printf("学院:%s\n参赛项目编号:%s\n是否检录(y/n):%c\n",temp.college,temp.item_id,temp.check);
        printf("参赛成绩:%.2lf\n排名:%d\n分数:%d分\n",temp.score,temp.rank,temp.fraction);
        cout<<"------------------------------------------------------------------------------------\n";
    }
}

//修改学生信息
void ChangeNode_stu(){
    student temp{};
    int pos;
    printf("请输入要修改的学号:");
    cin>>temp.id;
    pos=Stu_find(temp);
    if(pos==-1) {
        cout << "没有查找要修改的运动员!" << endl;
        return;
    }else {
        stu_list2.retrieve(pos,temp);
        cout<<"--------------------------------初始运动员信息-------------------------------------------\n";
        printf("姓名:%s\n学号:%s\n",temp.name,temp.id);
        switch (temp.sex[0]) {
            case 'a':printf("性别:男\n");break;
            case 'b':printf("性别:女\n");break;
        }
        printf("学院:%s\n参赛项目编号:%s\n是否检录(y/n):%c\n",temp.college,temp.item_id,temp.check);
        printf("参赛成绩:%.2lf\n排名:%d\n分数:%d分\n",temp.score,temp.rank,temp.fraction);
        cout<<"-------------------------------------------------------------------------------------\n";
        cout<<"--------------------------------新的运动员信息-----------------------------------------------\n";
        cout<<"\t请顺序输入:"<<endl;
        cout<<"\t\t姓名(20)\n\t\t学号(10)\n\t\t性别(a,b)\n\t\t参赛项目编号(6)"<<endl;
        cout<<"--------------------------------------------------------------------------------\n";
        cin>>temp.name>>temp.id>>temp.sex>>temp.item_id;
        int pos1=Stu_find(temp);
        if(pos1!=-1&& pos1!=pos ){
            cout << "\t该运动员已存在!" << endl;
            return;
        }
        if(Item_find(temp.item_id)==-1){
            cout << "\t参赛项目项目不存在" << endl;
            return;
        }  
        Stu_college_select(temp);
        stu_list2.replace(pos,temp);
    }
}


//删除学生信息
void DeleteNode_stu(){
    if(stu_list2.empty()){
        cout<<"\n\t列表为空!"<<endl;
        return;
    }
    student temp{};
    int pos;
    printf("请输入要删除的学号:");
    cin>>temp.id;
    pos=Stu_find(temp);
    if(pos==-1) {
        cout << "\t没有查找要删除的运动员!" << endl;
        return ;
    }else {
        stu_list2.remove(pos, temp);
        cout << "--------------------------------要删除的运动员-------------------------------------------\n";
        printf("姓名:%s\n学号:%s\n", temp.name, temp.id);
        switch (temp.sex[0]) {
            case 'a':
                printf("性别:男\n");
                break;
            case 'b':
                printf("性别:女\n");
                break;
        }
        printf("学院:%s\n参赛项目编号:%s\n是否检录(y/n):%c\n", temp.college, temp.item_id, temp.check);
        printf("参赛成绩:%.2lf\n排名:%d\n分数:%d分\n",temp.score,temp.rank,temp.fraction);
        cout << "-------------------------------------------------------------------------------------\n";
    }
    cout<<"\t删除成功!\n"<<endl;
}

//参赛前检录
void Check_stu(){
    student temp{};
    int pos;
    printf("请输入要检录的学号:");
    cin>>temp.id;
    pos=Stu_find(temp);
    if(pos==-1) {
        cout << "\t没有查找要检录的运动员!" << endl;
        return;
    }else {
        stu_list2.retrieve(pos,temp);
        temp.check='y';
        stu_list2.replace(pos,temp);
    }
    cout<<"\t检录成功!\n"<<endl;
}

//参赛成绩录入
void Input_stu(){
    student temp{};
    int pos;
    printf("请输入要录入成绩的学号:");
    cin>>temp.id;
    pos=Stu_find(temp);
    if(pos==-1) {
        cout << "\t没有查找要录入成绩的运动员!" << endl;
        return;
    }else {
        stu_list2.retrieve(pos,temp);
        if(temp.check=='n'){
            cout<<"\t该运动员未检录,不能录入成绩!"<<endl;
            return;
        }
        printf("请输入要录入的成绩:");
        cin>>temp.score;
        printf("请输入要录入的排名:");
        cin>>temp.rank;
        switch(temp.rank)
        {
            case 1:temp.fraction=3;break;
            case 2:temp.fraction=2;break;
            case 3:temp.fraction=1;break;
            default:temp.fraction=0;break;
        }
        stu_list2.replace(pos,temp);
    }
    cout<<"\t录入成绩成功!"<<endl;
    cout<<"\t得分:"<<temp.fraction<<endl;
}

//打印学生信息
void print_stu(student& temp) 
{
    printf("-----------------------------------学号:%s----------------------------------------\n", temp.id);
    printf("姓名:%s\n学号:%s\n", temp.name, temp.id);
    switch (temp.sex[0]) {
        case 'a':
            printf("性别:男\n");
            break;
        case 'b':
            printf("性别:女\n");
            break;
    }
    printf("学院:%s\n参赛项目编号:%s\n是否检录(y/n):%c\n", temp.college, temp.item_id, temp.check);
    printf("参赛成绩:%.2lf\n排名:%d\n分数:%d分\n",temp.score,temp.rank,temp.fraction);
    cout << "-------------------------------------------------------------------------------------\n";
}


//打印学生列表
void PrintList_stu(){
    cout<<"-----------------------------------共有"<<stu_list2.size()<<"名运动员------------------------------------------\n";
    cout<<"\t运动员信息如下:\n";
    stu_list2.traverse(print_stu);
}
#endif //STUDENT_H

College.h

#ifndef COLLEGE_H
#define COLLEGE_H

#include"Item.h"
#include"Student.h"
#include<algorithm>
int college_a[10] = { 0 }, college_b[10] = { 0 }, college_c[10] = { 0 };//存储每个学院的得分总数
pair<int, int> college_a_rank[10], college_b_rank[10], college_c_rank[10];//存储每个学院的排名
bool cmp(pair<int, int> a, pair<int, int> b)//比较函数,降序
{
    return a.first> b.first;
}
//学院分数统计与排序
void college_statistics()
{
    student temp_stu={};//创建一个临时学生对象
    item temp_item={};//创建一个临时项目对象
    for(int i=0;i<stu_list2.size();i++)
    {
        stu_list2.retrieve(i,temp_stu);
        int pos=Item_find(temp_stu.item_id);//查找项目位置
        item_list1.retrieve(pos,temp_item);
        int k=temp_stu.college_num;
        switch(temp_item.sex[0])
        {
            case 'a':
                college_a[k]=college_a[k]+temp_stu.fraction;
                break;
            case 'b':
                college_b[k]=college_b[k]+temp_stu.fraction;
                break;
            case 'c':
                college_c[k]=college_c[k]+temp_stu.fraction;
                break;
        }
    }
    for(int i=1;i<10;i++)
    {//初始化排名
        college_a_rank[i].first=college_a[i];
        college_a_rank[i].second=i;
        college_b_rank[i].first=college_b[i];
        college_b_rank[i].second=i;
        college_c_rank[i].first=college_c[i];
        college_c_rank[i].second=i;
    }
    sort(college_a_rank+1,college_a_rank+10,cmp);//排序
    sort(college_b_rank+1,college_b_rank+10,cmp);
    sort(college_c_rank+1,college_c_rank+10,cmp);
    cout<<"\t\t学院分数统计与排序如下:\n";
    cout<<"\t男子团体前 6 名:\n";
    for(int i=1;i<=6;i++)
    {
        cout<<"\t\t第"<<i<<"名为 "<<Stu_college_find(college_a_rank[i].second)
        <<"的分数为 "<<college_a_rank[i].first<<endl;
    }
    cout<<"\t女子团体前 6 名:\n";
    for(int i=1;i<=6;i++)
    {
        cout<<"\t\t第"<<i<<"名为 "<<Stu_college_find(college_b_rank[i].second)
        <<"的分数为 "<<college_b_rank[i].first<<endl;
    }
    cout<<"\t男女混合团体前 6 名:\n";
    for(int i=1;i<=6;i++)
    {
        cout<<"\t\t第"<<i<<"名为 "<<Stu_college_find(college_c_rank[i].second)
        <<"的分数为 "<<college_c_rank[i].first<<endl;
    }
}

#endif // COLLEGE_H

Text.h

#ifndef TEXT_H
#define TEXT_H

#include<iostream>
#include<fstream>
#include"Item.h"
#include"Student.h"
using namespace std;

//保存数据
void Save_text()
{
    ofstream outfile1("item_list1.txt");
    ofstream outfile2("stu_list2.txt");
    if(!outfile1||!outfile2)
    {
        cout<<"\t文件打开失败!\n"<<endl;
        return;
    }
    outfile1<<"运动会项目数据:\n";
    outfile1<<"项目编号 项目名称 参与项目的运动员性别 比赛日期(年 月 日)比赛时间(时 分 秒) 比赛人数\n";
    for(int i=0;i<item_list1.size();i++)
    {
        item temp_item={};
        item_list1.retrieve(i,temp_item);
        outfile1<<temp_item.id<<" "<<temp_item.name<<" "<<temp_item.sex<<" "
            <<temp_item.item_data.year<<" "<<temp_item.item_data.month<<" "<<temp_item.item_data.day<<" "
            <<temp_item.item_time.hour<<" "<<temp_item.item_time.minute<<" "<<temp_item.item_time.second<<" "
            <<temp_item.number_people;
        if(i!=item_list1.size()-1)outfile1<<"\n";
    }
    outfile2<<"运动会参赛运动员数据:\n";
    outfile2<<"运动员编号 姓名 性别 比赛项目编号 学院 是否检录 参赛成绩 排名 分数\n";
    for(int i=0;i<stu_list2.size();i++)
    {
        student temp_stu={};
        stu_list2.retrieve(i,temp_stu);
        outfile2<<temp_stu.id<<" "<<temp_stu.name<<" "<<temp_stu.sex
            <<" "<<temp_stu.item_id<<" "<<temp_stu.college_num<<" "
            <<temp_stu.college<<" "<<temp_stu.check<<" "<<temp_stu.score<<" "
            <<temp_stu.rank<<" "<<temp_stu.fraction;
        if(i!=stu_list2.size()-1)outfile2<<"\n";
    }
    outfile1.close();
    outfile2.close();
    cout<<"\t保存成功!\n"<<endl;
}


//读取数据
void Read_text()
{
    item_list1.clear();
    stu_list2.clear();
    ifstream infile1("item_list1.txt",ios::in);
    ifstream infile2("stu_list2.txt",ios::in);
    if(!infile1||!infile2)
    {
        cout<<"\t文件打开失败!\n"<<endl;
        return;
    }
    char s[100];
    item temp_item={};
    infile1.getline(s,100);
    infile1.getline(s,100);
    int i=0;
    while(infile1.peek()!=EOF)
    {
        infile1>>temp_item.id>>temp_item.name>>temp_item.sex
        >>temp_item.item_data.year>>temp_item.item_data.month>>temp_item.item_data.day
        >>temp_item.item_time.hour>>temp_item.item_time.minute>>temp_item.item_time.second
        >>temp_item.number_people;
        item_list1.insert(i++,temp_item);
    }
    student temp_stu={};
    infile2.getline(s,100);
    infile2.getline(s,100);
    int  j=0;
    while(infile2.peek()!=EOF)
    {
        infile2>>temp_stu.id>>temp_stu.name>>temp_stu.sex>>temp_stu.item_id>>temp_stu.college_num
        >>temp_stu.college>>temp_stu.check>>temp_stu.score>>temp_stu.rank>>temp_stu.fraction;
        stu_list2.insert(j++,temp_stu);
    }
    infile1.close();
    infile2.close();
    cout<<"\t读取成功!\n"<<endl;
}

#endif // TEXT_H

main.cpp

// #include "List1.h"
// #include "List1.cpp"
// #include <iostream>
// using namespace std;
// // test List1 mechanism
// void write_entry(char& c)
// {
//    cout << c;
// }
// int  main()
// {
//    char x;
//    List1<char> c_list; // a list of characters, initialized empty
//    cout << "List is empty, it has " << c_list.size() << " items.\n";
//    cout << "Enter characters and the program adds them to the list.\n";
//    cout << "Use Enter key (newline) to terminate the input.\n";
//    cout << "When ListSize() is 3, the element will be inserted at the ";
//    cout << "front of the list.\n The others will appear at the back.\n";
//    while (!c_list.full() && (x = cin.get()) != '\n')
//        if (c_list.size() == 3) c_list.insert(0, x);
//        else c_list.insert(c_list.size(), x);
//    cout << "The list has " << c_list.size() << " items.\n";
//    cout << "The function c_list.full(), got " << c_list.full();
//    if (c_list.full()) cout << " because the list is full.\n";
//    else cout << " because the list is NOT full.\n";
//    cout << "c_list.empty(), expecting 0, got " << c_list.empty() << ".\n";
//    cout << "c_list.traverse(write_entry) output: ";
//    c_list.traverse(write_entry);
//    cout << "\n";
//    c_list.clear();
//    cout << "Cleared the list, printing its contents:\n";
//    c_list.traverse(write_entry);
//    cout << "\n";
//    cout << "Enter characters and the program adds them to the list.\n";
//    cout << "Use Enter key (newline) to terminate the input.\n";
//    cout << "When ListSize() is < 3, the element will be inserted at the ";
//    cout << "front of the list.\n The others will appear at the back.\n";
//    while (!c_list.full() && (x = cin.get()) != '\n')
//        if (c_list.size() < 3) c_list.insert(0, x);
//        else c_list.insert(c_list.size(), x);
//    c_list.traverse(write_entry);
//    cout << "\n";
//    system("pause");
// }


// #include "List2.h"
// #include "List2.cpp"
// #include <iostream>
// using namespace std;
// // test List1 mechanism
// void write_entry(char& c)
// {
//    cout << c;
// }
// int  main()
// {
//    char x;
//    List2<char> c_list; // a list of characters, initialized empty
//    cout << "List is empty, it has " << c_list.size() << " items.\n";
//    cout << "Enter characters and the program adds them to the list.\n";
//    cout << "Use Enter key (newline) to terminate the input.\n";
//    cout << "When ListSize() is 3, the element will be inserted at the ";
//    cout << "front of the list.\n The others will appear at the back.\n";
//    while (!c_list.full() && (x = cin.get()) != '\n')
//        if (c_list.size() == 3) c_list.insert(0, x);
//        else c_list.insert(c_list.size(), x);
//    cout << "The list has " << c_list.size() << " items.\n";
//    cout << "The function c_list.full(), got " << c_list.full();
//    if (c_list.full()) cout << " because the list is full.\n";
//    else cout << " because the list is NOT full.\n";
//    cout << "c_list.empty(), expecting 0, got " << c_list.empty() << ".\n";
//    cout << "c_list.traverse(write_entry) output: ";
//    c_list.traverse(write_entry);
//    cout << "\n";
//    c_list.clear();
//    cout << "Cleared the list, printing its contents:\n";
//    c_list.traverse(write_entry);
//    cout << "\n";
//    cout << "Enter characters and the program adds them to the list.\n";
//    cout << "Use Enter key (newline) to terminate the input.\n";
//    cout << "When ListSize() is < 3, the element will be inserted at the ";
//    cout << "front of the list.\n The others will appear at the back.\n";
//    while (!c_list.full() && (x = cin.get()) != '\n')
//        if (c_list.size() < 3) c_list.insert(0, x);
//        else c_list.insert(c_list.size(), x);
//    c_list.traverse(write_entry);
//    cout << "\n";
//    system("pause");
// }


#include <iostream>
#include"Item.h"
#include"Student.h"
#include"College.h"
#include"Text.h"
int main() 
{
    Read_text();
    while(1)
    {
        printf("\n\t\t运 动 会 信 息 管 理 系 统\n");
        cout << "\t可选操作:\n";
        cout << "\t\tw.运动项目管理系统\n\t\ts.运动员管理系统\n\t\ta.学院分数统计与排序\n\t\tq.永久性存储且退出\n";
        cout << "\t请选择操作:";
        char choice;
        cin >> choice;
        cout<<endl;
        bool flag=false;
        switch (choice) {
            case 'W':
            case 'w':
                cout << "\t运 动 项 目 管 理 系 统" << endl;
                while (1) {
                    switch (menu_item_select()) {
                        case 1:
                            printf("\t***********************************************\n");
                            printf("\t\t* 运 动 项 目 的 建 立 *\n"); //顺序表
                            printf("\t***********************************************\n");
                            CreateList_item();
                            break;
                        case 2:
                            printf("\t***********************************************\n");
                            printf("\t\t* 运 动 项 目 的 添 加 *\n");
                            printf("\t***********************************************\n");
                            InsertNode_item();
                            break;
                        case 3:
                            printf("\t***********************************************\n");
                            printf("\t\t* 运 动 项 目 的 查 询 *\n");
                            printf("\t***********************************************\n");
                            ListFind_item();
                            break;
                        case 4:
                            printf("\t***********************************************\n");
                            printf("\t\t* 运 动 项 目 的 修 改 *\n");
                            printf("\t***********************************************\n");
                            ChangeNode_item(); //修改结点
                            break;
                        case 5:
                            printf("\t***********************************************\n");
                            printf("\t\t* 运 动 项 目 的 删 除 *\n");
                            printf("\t***********************************************\n");
                            DeleteNode_item(); //删除结点
                            break;
                        case 6:
                            printf("\t***********************************************\n");
                            printf("\t\t* 运 动 项 目 的 输 出 *\n");
                            printf("\t***********************************************\n");
                            PrintList_item();
                            break;
                        case 0:
                            printf("\t\t运 动 项 目 管 理 系 统 退 出 成 功 ! \n\n");
                            flag=true;
                            break;
                        default:
                            cout<<"\t输入错误,请重新输入!\n";
                            break;
                        }
                    cout<<endl;
                    if(flag){
                         flag=false;
                         break;
                    }
                }
                break;
            case 'S':
            case 's':
                    cout << "\t运 动 员 管 理 系 统" << endl;
                    while (1) {
                        switch (menu_stu_select()) {
                            case 1:
                                printf("\t***********************************************\n");
                                printf("\t\t* 运 动 员 信 息 的 建 立 *\n"); //顺序表
                                printf("\t***********************************************\n");
                                CreateList_stu();
                                break;
                            case 2:
                                printf("\t***********************************************\n");
                                printf("\t\t* 运 动 员 信 息 的 添 加 *\n");
                                printf("\t***********************************************\n");
                                InsertNode_stu();
                                break;
                            case 3:
                                printf("\t***********************************************\n");
                                printf("\t\t* 运 动 员 信 息 的 查 询 *\n");
                                printf("\t***********************************************\n");
                                ListFind_stu();
                                break;
                            case 4:
                                printf("\t***********************************************\n");
                                printf("\t\t* 运 动 员 信 息 的 修 改 *\n");
                                printf("\t***********************************************\n");
                                ChangeNode_stu(); //修改结点
                                break;
                            case 5:
                                printf("\t***********************************************\n");
                                printf("\t\t* 运 动 员 信 息 的 删 除 *\n");
                                printf("\t***********************************************\n");
                                DeleteNode_stu(); //删除结点
                                break;
                            case 6:
                                printf("\t***********************************************\n");
                                printf("\t\t* 参 赛  前 检 录 *\n");
                                printf("\t***********************************************\n");
                                Check_stu();
                                break;
                            case 7:
                                printf("\t***********************************************\n");
                                printf("\t\t* 参 赛 成 绩 录 入 *\n");
                                printf("\t***********************************************\n");
                                Input_stu();
                                break;
                            case 8:
                                printf("\t***********************************************\n");
                                printf("\t\t* 运 动 员 信 息 的 输 出 *\n");
                                printf("\t***********************************************\n");
                                PrintList_stu();
                                break;
                            case 0:
                                printf("\t\t运 动 员 管 理 系 统 退 出 成 功 ! \n\n");
                                flag=true;
                                break;
                            default:
                                cout<<"\t输入错误,请重新输入!\n";
                                break;
                        }
                        cout<<endl;
                        if(flag){
                            flag=false;
                            break;
                        }
                    }
                    break;
            case 'A':
            case 'a':
                college_statistics();
                cout<<endl;
                break;
            case 'Q':
            case 'q':
                Save_text();
                system("pause");
                return 0;
            default:
                cout<<"\t输入错误,请重新输入!\n";
                break;
        }
    }
}
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

NeutronShip

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值