C++实现简单的学生管理系统实现简单的学生管理系统
本文给大家分享的是使用C++实现的简单的学生管理系统的代码,主要是通过链表来实现,非常简洁,有需要的
小伙伴可以参考下。
C++实现简单的学生管理系统
//Student.cpp
#include<iostream>
using namespace std;
struct Stu
{
char no[10];
char name[16];
int math;
int chi;
double ave;
};
class Student
{
public:
Stu st;
Student * next;
public:
Student(){}
Student(Stu s)
{
st=s;
next=NULL;
st.ave=(st.math+st.chi)/2.0;
}
void setst(Stu s)
{
st=s;
st.ave=(st.math+st.chi)/2.0;
}
Stu getst()
{
return st;
}
void show()
{
cout<<"----------------------------"<<endl;
cout<<"学号:"<<st.no<<endl;
cout<<"姓名:"<<st.name<<endl;
cout<<"数学成绩:"<<st.math<<endl;
cout<<"语文成绩:"<<st.chi<<endl;
cout<<"平均成绩:"<<st.ave<<endl;
cout<<"----------------------------"<<endl;
}
};
//main.cpp
#include<fstream>
#include"Student.cpp"
using namespace std;
Student * create_List();
void traverse_List(Student * pHead);
bool is_empty(Student * pHead);
int length_List(Student * pHead);
bool insert_List(Student * pHead,int position,Stu st);
bool delete_List(Student * pHead,int position,Stu * st);
void sort_List(Student * pHead);
void menu_select();
void handle_menu(int s);
void outFile();
Student * inFile();
void delFile();
Student * pHead;