本篇内容主要讲解“C++如何实现考勤管理系统”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“C++如何实现考勤管理系统”吧!
设计一考勤管理系统,记录学生的缺课情况
设计学生类;
2、设计课程类;
3、设计考勤类;
4、录入学生的缺课情况;
5、修改某个学生的缺课情况;
6、查询某个学生的缺课情况;
7、统计一段时间内,旷课学生的名单和次数
仅供参考,尚有不足,请多多指正!
#include <iostream>#include <cstring>using namespace std;class Student{ public: void setname(char *setname) { strcpy(name,setname); } void setcarname(char *setcarname) { strcpy(carname,setcarname); } void setseating_capacity(char *setseating_capacity) { strcpy(seating_capacity,setseating_capacity); } void setidentifynumber(char *setidentifynumber) { strcpy(identifynumber,setidentifynumber); } char *getname() { char *setname=name; return setname; } char *getcarname() { char *setcarname=carname; return setcarname; } char *getsetseating_capacity() { char *setseating_capacity=seating_capacity; return setseating_capacity; } char *getidentifynumber() { char *setidentifynumber=identifynumber; return setidentifynumber; } private: char name[30]; char carname[30]; char seating_capacity[30]; char identifynumber[30];};class Course:public Student{ public: void setcoursename(char *setcoursename) { strcpy(coursename,setcoursename); } void setcoursetime(char *setcoursetime) { strcpy(coursetime,setcoursetime); } void setcourseplace(char *setcourseplace) { strcpy(courseplace,setcourseplace); } char *getcoursename() { char *setcoursename; setcoursename=coursename; return setcoursename; } char *getcoursetime() { char *setcoursetime; setcoursetime=coursetime; return setcoursetime; } char *getcourseplace() { char *setcourseplace; setcourseplace=courseplace; return setcourseplace; } private: char coursename[30]; char coursetime[30]; char courseplace[30];}; class Attendence:public Course{ public: void setattendence(int setattendence) { int i=0; attendence[i]=setattendence; i++; } int *getattendence() { int *setattendence; setattendence=attendence; return setattendence; } private: int attendence[30];}; int input(Student n[],Student i[],Course cn[],Course ct[],Course cp[],Attendence a[]);int modify(Student i[],Course cn[],Course ct[],Course cp[],Attendence attendence[],int totalnumber);int search(Student n[],Student i[],Course cn[],Course ct[],Course cp[],Attendence a[],int totalnumber);int statistic(Student n[],Student i[],Course cn[],Course ct[],Course cp[],Attendence a[],int totalnumber);void bubble(int arr[],int len);Student n[20];Student i[20];Course cn[20];Course ct[20];Course cp[20];Attendence a[20];int totalnumber=0;char name[30];char identifynumber[30];char coursename[30];char coursetime[30];char courseplace[30];int attendence;int array[30];int att[30];int main() { while(1) { cout<<"---------吉林大学珠海学院---------\n" <<" 学生考勤管理系统\n\n" <<" 1.录入学生缺课信息\n" <<" 2.修改学生缺课记录\n" <<" 3.查询学生缺课情况\n" <<" 4.统计一段时间内学生旷课情况\n" <<" 5.退出系统\n\n" <<"------------------------------"<<endl; int num; for(;;) { cout<<"请选择需要执行的功能序号(1-5):"; cin>>num; if(num>=1&&num<=5) break; else continue; } cout<<endl; switch(num){ case 1:{ input(n,i,cn,ct,cp,a); break; } case 2:{ modify(i,cn,ct,cp,a,totalnumber); break; } case 3:{ search(n,i,cn,ct,cp,a,totalnumber); break ; } case 4:{ statistic(n,i,cn,ct,cp,a,totalnumber); break; } case 5:exit(0); } } }int input(Student n[],Student i[],Course cn[],Course ct[],Course cp[],Attendence a[]){ cout<<"----------请开始输入----------\n"; cout<<"请输入将录入系统的人数:"; cin>>totalnumber; cout<<endl; for(int counter=0;counter<totalnumber;counter++) { cout<<"学生姓名:"; cin>>name; n[counter].setname(name); cout<<"学生学号:"; cin>>identifynumber; i[counter].setidentifynumber(identifynumber); cout<<"课程名称:"; cin>>coursename; cn[counter].setcoursename(coursename); cout<<"课程时间(星期几,第几节课):"; cin>>coursetime; ct[counter].setcoursetime(coursetime); cout<<"课程地点:"; cin>>courseplace; cp[counter].setcourseplace(courseplace); cout<<"缺课次数:"; cin>>attendence; a[counter].setattendence(attendence); array[counter]=attendence; cout<<'\n'; } return 1;}int modify(Student i[],Course cn[],Course ct[],Course cp[],Attendence a[],int totalnumber){ int inputnumber; do{ char id[8]; cout<<"请输入学生学号:"; cin>>id; cout<<endl; if(1) { for(int counter=0;counter<totalnumber;counter++) { if(strcmp(id,i[counter].getidentifynumber())==0) { int num; cout<<"请选择需要修改信息的种类:" <<"\n1.课程名称\n" <<"2.课程时间\n" <<"3.课程地点\n" <<"4.缺课次数\n"; for(;;) { cout<<"请输入需要修改信息的代号(1-4):"; cin>>num; if(num>=1&&num<=4) break; else continue; } cout<<endl; switch(num){ case 1:{ cout<<"请输入修改后的课程名称:"; cin>>coursename; cn[counter].setcoursename(coursename); cout<<'\n'; break; } case 2:{ cout<<"请输入修改后的课程时间(星期几,第几节课):"; cin>>coursetime; ct[counter].setcoursetime(coursetime); cout<<'\n'; break; } case 3:{ cout<<"请输入修改后的课程地点:"; cin>>courseplace; cp[counter].setcourseplace(courseplace); cout<<'\n'; break; } case 4:{ cout<<"请输入修改后的缺课次数:"; cin>>attendence; a[counter].setattendence(attendence); array[counter]=attendence; cout<<'\n'; break; } } } } } else { cout<<"无该学生缺课信息!\n" <<"请再次确认输入学号无误\n\n"; } for(;;) { cout<<"重新查询请输入1|返回目录请输入0\n"; cin>>inputnumber; if(inputnumber==1||inputnumber==0) break; else continue; } }while(inputnumber==1); return 1;}int search(Student n[],Student i[],Course cn[],Course ct[],Course cp[],Attendence a[],int totalnumber){ int inputnumber; do{ char ids[8]; char *identify=ids; cout<<"请输入学生学号:"; cin>>ids; cout<<endl; strcpy(ids,identify); if(1) { for(int counter=0;counter<totalnumber;counter++) { if(strcmp(ids,i[counter].getidentifynumber())==0) { cout<<"学生姓名:"<<n[counter].getname() <<"\n学生学号:"<<i[counter].getidentifynumber() <<"\n缺课课程名称:"<<cn[counter].getcoursename() <<"\n缺课课程日期:"<<ct[counter].getcoursetime() <<"\n缺课时间:"<<cp[counter].getcourseplace() <<"\n缺课次数:"<<*a[counter].getattendence()<<"\n"; } } } else cout<<"无该同学数据"; break; cout<<'\n'<<endl; for(;;) { cout<<"重新查询请输入1|返回目录请输入0\n\n"; cin>>inputnumber; if(inputnumber==0||inputnumber==1) break; else continue; } }while(inputnumber==1); return 1;}int statistic(Student n[],Student i[],Course cn[],Course ct[],Course cp[],Attendence a[],int totalnumber){ int inputnumber; for(int index=0;index<30;index++) att[index]=index; if(totalnumber==0) cout<<"数据库无信息\n\n"; else if(totalnumber==1) cout<<"学生姓名:"<<n[0].getname() <<"\n学生学号:"<<i[0].getidentifynumber() <<"\n缺课课程名称:"<<cn[0].getcoursename() <<"\n缺课课程日期:"<<ct[0].getcoursetime() <<"\n缺课时间:"<<cp[0].getcourseplace() <<"\n缺课次数:"<<*a[0].getattendence()<<"\n\n"; else if(1) { for(int counter=0;counter<totalnumber;counter++) { if(a[counter].getattendence()<a[counter].getattendence()+1) { bubble(array,totalnumber); } else if(a[counter].getattendence()==a[counter+1].getattendence()) { if(strcmp(i[counter].getidentifynumber(),i[counter+1].getidentifynumber())>0) { int temp; int a=counter; int b=counter+1; temp=a; a=b; b=temp; } } } for(int index=0;index<totalnumber;index++) { cout<<"学生姓名:"<<n[att[index]].getname() <<"\n学生学号:"<<i[att[index]].getidentifynumber() <<"\n缺课课程名称:"<<cn[att[index]].getcoursename() <<"\n缺课课程日期:"<<ct[att[index]].getcoursetime() <<"\n缺课时间:"<<cp[att[index]].getcourseplace() <<"\n缺课次数:"<<*a[att[index]].getattendence()<<"\n\n"; } } cout<<"返回目录请输入0\n"; cin>>inputnumber; if(inputnumber==0) return 1;}void bubble(int arr[],int len){ int i,j,temp; int t; for(i=0;i<len-1;i++) { for(j=0;j<len-1-i;j++) { if(arr[j]<arr[j+1]) { temp=arr[j]; arr[j]=arr[j+1]; arr[j+1]=temp; t=att[j]; att[j]=att[j+1]; att[j+1]=t; } } }}
到此,相信大家对“C++如何实现考勤管理系统”有了更深的了解,不妨来实际操作一番吧!这里是编程网网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!