C++实现简单的学生管理系统

//Student.cpp

#include

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<

cout<

cout<

cout<

cout<

cout<

cout<

}

};

//main.cpp

#include

#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;

void main()

{

menu_select();

}

void menu_select()

{

int s;

cout<

cout<

cout<

cout<

cout<

cout<

cout<

cout<

cout<

cout<

cout<

cin>>s;

handle_menu(s);

}

void handle_menu(int s)

{

switch (s)

{

case 1:

{

system("cls");

pHead=create_List();

system("cls");

menu_select();

break;

}

case 2:

{

if(NULL==pHead)

{

cout<

getchar();

getchar();

system("cls");

menu_select();

}

system("cls");

sort_List(pHead);

traverse_List(pHead);

getchar();

getchar();

system("cls");

menu_select();

break;

}

case 3:

{

if(pHead!=NULL)

{

system("cls");

outFile();

system("cls");

menu_select();

}

system("cls");

menu_select();

break;

}

case 4:

{

system("cls");

pHead=inFile();

system("cls");

menu_select();

break;

}

case 5:

{

system("cls");

delFile();

system("cls");

menu_select();

break;

}

case 6:

{

if(NULL==pHead)

{

cout<

getchar();

getchar();

system("cls");

menu_select();

}

system("cls");

int num;

Stu st;

traverse_List(pHead);

cout<

cin>>num;

cout<

cout<

cin>>st.no;

cout<

cin>>st.name;

cout<

cin>>st.math;

cout<

cin>>st.chi;

if(insert_List(pHead,num-1,st))

{

cout<

}

else

{

cout<

}

getchar();

getchar();

system("cls");

menu_select();

break;

}

case 7:

{

if(NULL==pHead)

{

cout<

getchar();

getchar();

system("cls");

menu_select();

}

int num;

Stu * st=(Stu *)malloc(sizeof(Stu));

traverse_List(pHead);

cout<

cin>>num;

if(delete_List(pHead,num,st))

{

cout<

cout<no<name<

}

else

{

cout<

}

getchar();

getchar();

system("cls");

menu_select();

break;

}

case 8:

{

if(NULL!=pHead)

{

system("cls");

cout<

getchar();

getchar();

system("cls");

menu_select();

}

else

{

cout<

getchar();

getchar();

system("cls");

menu_select();

}

break;

}

case 9:

{

system("cls");

cout<

exit(0);

break;

}

}

}

void delFile()

{

ofstream fileout;

fileout.open("c:\\kcsj.txt",ios_base::out);

fileout<

fileout.close();

}

Student * inFile()

{

Student * pHead=(Student *)malloc(sizeof(Student));

if(NULL==pHead)

{

cout<

exit(0);

}

Student * pTail=pHead;

pTail->next=NULL;

ifstream in("c:\\kcsj.txt");

if (!in.is_open())

{

cout << "Error opening file"<

exit(0);

}

while (!in.eof())

{

Stu st;

in.read(reinterpret_cast(&st), sizeof(st));

if (in.fail())

{

break;

}

Student * pNew=new Student();

if(NULL==pNew)

{

printf("分配失败,程序终止\n");

exit(0);

}

pNew->setst(st);

pTail->next=pNew;

pNew->next=NULL;

pTail=pNew;

}

in.close();

return pHead;

}

void outFile()

{

ofstream out;

out.open("c:\\kcsj.txt",ios_base::out|ios_base::app|ios::binary);

if(!out)

{

cout<

out.close();

out.open("stu.dat",ios_base::out|ios::binary);

}

else

{

out.close();

out.open("c:\\kcsj.txt",ios_base::out|ios_base::app|ios::binary);

}

Student * temp=pHead->next;

while(temp!=NULL)

{

Stu st=temp->getst();

out.write(reinterpret_cast(&st), sizeof(st));

temp=temp->next;

}

out.close();

}

Student * create_List()

{

int len;

Student * pHead=(Student *)malloc(sizeof(Student));

if(NULL==pHead)

{

cout<

exit(0);

}

Student * pTail=pHead;

pTail->next=NULL;

cout<

cin>>len;

for(int i=0;i

{

Stu st;

cout<

cin>>st.no;

cout<

cin>>st.name;

cout<

cin>>st.math;

cout<

cin>>st.chi;

Student * pNew=new Student();

if(NULL==pNew)

{

printf("分配失败,程序终止\n");

exit(0);

}

pNew->setst(st);

pTail->next=pNew;

pNew->next=NULL;

pTail=pNew;

}

return pHead;

}

void traverse_List(Student * pHead)

{

int i=1;

Student * temp=pHead->next;

while(temp!=NULL)

{

cout<

temp->show();

temp=temp->next;

i++;

}

}

bool is_empty(Student * pHead)

{

if(NULL==pHead->next)

{

return true;

}

else

{

return false;

}

}

int length_List(Student * pHead)

{

int len=0;

Student * temp=pHead->next;

while(temp)

{

len++;

temp=temp->next;

}

return len;

}

bool insert_List(Student * pHead,int position,Stu st)

{

int i=0;

Student * p=pHead;

while(NULL!=p&&i

{

p=p->next;

i++;

}

if(i>position-i||NULL==p)

{

return false;

}

Student * pNew=(Student *)malloc(sizeof(Student));

if(NULL==pNew)

{

cout<

exit(0);

}

pNew->setst(st);

pNew->next=p->next;

p->next=pNew;

return true;

}

bool delete_List(Student * pHead,int position,Stu * st)

{

int i=0;

Student * p=pHead;

while(NULL!=p->next&&i

{

p=p->next;

i++;

}

Student * q=p->next;

*st=q->getst();

p->next=p->next->next;

free(q);

q=NULL;

return true;

}

void sort_List(Student * pHead)

{

Student * p,* q;

Stu temp;

int i,j;

int len=length_List(pHead);

for(i=0,p=pHead->next;inext)

{

for(j=i+1,q=p->next;jnext)

{

if(q->st.ave>p->st.ave)

{

temp=q->st;

q->st=p->st;

p->st=temp;

}

}

}

}

以上所述就是本文的全部内容了,希望大家能够喜欢。

学生签到系统c代码_C++实现简单的学生管理系统相关推荐

  1. 学生签到系统c代码_C语言学生管理系统源码分享

    1 大家好2 我就是如假包换的...陈玲3 自从运营了C语言程序设计微信公众号4 很多粉丝都给我备注5 ...奇葩6 实在是不敢当7 也被人开始叫玲玲姐8 我知道9 很多人都想看我出境10 我本人也有 ...

  2. 学生签到系统c代码_C++实现学生考勤信息管理系统

    学生考勤信息管理系统记录了学生的缺课情况,它包括: 缺课日期.第几节课.课程名称.学生姓名.学生学号.缺课类型(迟到.请假及旷课).系统具有以下功能: 1).录入学生的缺课记录: 2).修改某个学生的 ...

  3. 学生签到系统c代码_C语言实现简单学生学籍管理系统

    #include #include #include #include #define N 100 /*存储100个学生的学籍信息*/ int flag; /*标记是否登录*/ struct date ...

  4. 学生签到系统c代码_学生考勤系统源代码

    - 1 - 学生考勤系统源代码 void lace(int n)  /* 花边函数 */ { int i; for(i=0;i { putchar('*');   /* 输出 n 个 **/ } } ...

  5. 用HTML写一个学生签到系统

    好的. 这是一个简单的学生签到系统的 HTML 代码: <html><head><title>学生签到系统</title></head>&l ...

  6. java学生签到系统视频教程_手把手教你做一个Java web学生信息、选课、签到考勤、成绩管理系统附带完整源码及视频开发教程...

    四个阶段的Java web学生信息系统视频教程终于录制完成了,系统用到的知识点有:jsp+servlet+mysql+jquery+ajax,前端采用的是当下最流行的easyui管理框架,全部采用面向 ...

  7. java学生签到系统视频教程_Java web学生信息、选课、签到考勤、成绩管理系统附带完整源码及视频开发教程...

    四个阶段的Java web学生信息系统视频教程终于录制完成了,系统用到的知识点有:jsp+servlet+mysql+jquery+ajax,前端采用的是当下最流行的easyui管理框架,全部采用面向 ...

  8. 计算机课程设计SSH高校学生选课系统【代码讲解+安装调试+文档指导】

  9. 学生信息系统求助_Student Information Management -一个简单的学生信息管理系统(持续更新2)...

    这次更新的内容 1:优化了增加学生信息的函数 2:   增加了删除学生信息的功能 系统图 图片发自简书App 第一次见到的库和函数 #include "memory.h" void ...

  10. python开发系统-python3+django2开发一个简单的人员管理系统

    一.基础环境准备 windows环境: Pycharm python3.6 Django2.0.1 Mysql5.7 安装django 在pycharm terminal 控制台执行: python3 ...

最新文章

  1. 语义分割--Pixel Deconvolutional Networks
  2. (iOS-框架封装)iOS设计模式——MVC模式
  3. linux网站目录大小写,Linux服务器url区分大小写如何解决
  4. Kubernetes对象中的PersistentVolume、PersistentVolumeClaim和StorageClass的概念关系
  5. 【机器学习】快速入门机器学习
  6. 女神节爆猛料!. NET程序员男女比例公布!
  7. 云栖专辑 | 阿里开发者们的第19个感悟:Simple is better.
  8. 2021上半年朋友圈都在传的10本书,找到了
  9. CentOS 7如何配置yum源
  10. drools 7.x 决策表转drl
  11. MapReduce案例
  12. 我的第一个全栈 Web 应用程序
  13. Tensorflow随笔——命令行参数
  14. 有赞大裁员:裁员会超过1500人,加盟4年半的百度副总裁也已离职
  15. CCD与CMOS的区别
  16. 解决问题,别扩展问题
  17. 第16课:郭盛华课程PHP文件打开,读取
  18. 【工具】SMART原则的分析举例注意事项
  19. 若依前后端分离密码修改成功,登录提示用户名或密码不正确。
  20. 06-jQuery属性操作

热门文章

  1. 哨兵系列卫星_国外卫星典型应用
  2. 安装moodle3.6
  3. rpcbind 服务启动失败
  4. iPhoneXR苹果手机中文电路原理图纸
  5. 卫星通信常用专业词汇
  6. 世纪联华开了家新零售门店,网易严选也要入驻
  7. 【强烈推荐】Java入门基础笔记,超全!
  8. 负载均衡与服务器架构
  9. 如何复制百度文库的内容
  10. android imagebutton 动画,Android中ImageButton的三种点击效果—点击变化,点一次换一张,逐帧动画的实现...