学生考勤管理系统源代码(共10页).docx
精选优质文档-倾情为你奉上#include<iostream>#include<cstring>#include<windows.h>using namespace std;class timepublic:time(int y=0,int m=0,int d=0)year=y;month=m;day=d;time()protected:int year,month,day;/信息类class xinxi:public time public:xinxi() tiaoshu+;xinxi()tiaoshu-;void setname(char *n)strcpy(name,n);void settime(int y,int m,int d)year=y;month=m;day=d;void setqklx(char *qk)strcpy(queke,qk);void setjieci(char *jc)strcpy(jieci,jc);void setkechen(char *kc)strcpy(kechen,kc);char *getname()char *n;n=name;return n;char *getqklx()char *qk=queke;return qk;char *getjieci()char *jc;jc=jieci;return jc;char *getkechen()char *gk;gk=kechen;return gk;int *gettime();private:char name20;/姓名char jieci3,kechen10,queke10;int tm3;static int tiaoshu;int xinxi:tiaoshu=0;int *xinxi:gettime()int *t;t=tm;tm0=year;tm1=month;tm2=day;return t;class qkechen:public xinxipublic:qkechen()kcshu+;qkechen()kcshu-;int getrc(xinxi st1,int n,int j);char qkn20;/公有数据成员private:int renci;static int kcshu;/静态数据成员;int qkechen:kcshu=0;int qkechen:getrc(xinxi st1,int n,int j)renci=0;renci+;for(int i=0;i<n;i+)if(*(st1i+1.gettime()+1)=*(st1j.gettime()+1)&&*(st1i+1.gettime()+2)=*(st1j.gettime()+2)if(strcmp(qkn,st1i.getkechen()=0)renci+;return renci;class qstu:public xinxipublic:qstu()qst+;qstu()qst-;void print(xinxi &st1);int getjs(xinxi st1,int n,int j);int setjs(int js=0)jieshu=js;char qstn20;private:int jieshu;static int qst; /静态数据成员;int qstu:qst=0;void qstu:print(xinxi &st1)cout<<"|缺课日期 |"<<"第几节课 |"<<"课程名称 |"<<"缺课类型|"<<endl;cout<<"|"<<*st1.gettime()<<"|"<<*(st1.gettime()+1)<<*(st1.gettime()+2)<<"|"<<st1.getjieci()<<"|"<<st1.getkechen()<<"|"<<st1.getqklx()<<"|"<<endl;int qstu:getjs(xinxi st1,int n,int j)int i=0,js=0;xinxi min;if(*(st1j.getjieci()+2)!='0')js=+2;elsejs+;for(i=0;i<n;i+)if(*(st1i+1.gettime()+1)=*(st1j.gettime()+1)&&*(st1i+1.gettime()+2)=*(st1j.gettime()+2)if(strcmp(st1i+1.getname(),qstn)=0)if(*(st1i.getjieci()+2)!='0')js=+2;elsejs+;jieshu=js;return jieshu;/函数声明int shuru(xinxi st1);void chaxun(xinxi st1,qstu qt);void xiugai(xinxi st1,int n);void tongji1(xinxi st1,qstu qt1);void tongji2(xinxi st1,qkechen qk1);void caidan();void xiansi(xinxi &st1);void setqstn(xinxi st1,qstu qt1,int n);void setqkn(xinxi st1,qkechen qk,int n);/全局变量int g,k=1,b=1;int q=-1;char name20,kechen10,queke10,jieci3;int y,m,d;/主函数int main()xinxi tl15;/定义 15条信息类对象qstu qt10;qkechen qk6;int ch;while(1)cout<<"*欢迎进入学生考勤管理系统!*"<<endl;caidan();cout<<"-请选择菜单项:"<<endl;cin>>ch;switch(ch)case 1: g=shuru(tl); break;case 2: xiugai(tl,g); break;case 3: chaxun(tl,qt); break;case 4: tongji1(tl,qt); break;case 5: tongji2(tl,qk); break;case 6: exit(0);return 0;void caidan() system("color A");cout<<"*"<<endl;cout<<"*学生考勤管理系统*"<<endl;cout<<"*"<<endl;cout<<"1.-录入学生的缺课记录-*"<<endl; cout<<"2.-修改学生的缺课记录-*"<<endl;cout<<"3.-查询学生的缺课情况-*"<<endl;cout<<"4.-统计某段时间内旷课学生姓名及旷课节数-*"<<endl;cout<<"5.-统计某段时间内旷课的课程及旷课人次-*"<<endl;cout<<"6.-退出系统-*"<<endl;/输入函数int shuru(xinxi st1) char a;cout<<"-输入开始!-"<<endl;do q+;cout<<"请输入学生姓名"<<endl;cin>>name;st1q.setname(name);cout<<"请输入课程名称"<<endl;cin>>kechen;st1q.setkechen(kechen);cout<<"请输入缺课日期"<<endl;cin>>y>>m>>d;st1q.settime(y,m,d);cout<<"请输入缺课类型"<<endl;cin>>queke;st1q.setqklx(queke);cout<<"请输入缺课节次"<<endl;cin>>jieci;st1q.setjieci(jieci);cout<<"是否还要继续输入:(y/n)"<<endl;cin>>a;while(a='y');return q+1;void xiugai(xinxi st1,int n)int k=1,j=0,a10;int flgh;int h;while(k=1) cout<<"请输入你要修改缺课记录的学生姓名"<<endl;cin>>name;flgh=0;for(int i=0;i<n;i+)if(strcmp(name,st1i.getname()=0)do aj=i;cout<<"1.修改日期 2.修改节次 3.修改课程名称 4.修改缺课类型"<<endl;cout<<"请输入要选择的数值(1,2,3,4)"<<endl;int b;cin>>b;if(b=1) cout<<"请输入新日期"<<endl;cin>>y>>m>>d;st1i.settime(y,m,d);else if(b=2)cout<<"请输入新节次"<<endl;cin>>jieci;st1i.setjieci(jieci);else if(b=3)cout<<"请输入新课程名称"<<endl;cin>>kechen;st1i.setkechen(kechen);else if(b=4) cout<<"请输入新缺课类型"<<endl;cin>>queke;st1i.setqklx(queke);flgh=1;j+;while(b<1|b>4);if(flgh=0)cout<<"没有你要找的学生姓名,请重试要退出请按 0"<<endl;cin>>k;elsecout<<"还要继续吗(10)退出请按 0"<<endl;cin>>k;for(int i=0;i<j;i+)h=ai;xiansi(st1h);void chaxun(xinxi st1,qstu qt)char n='y'int u10;while(n='y')int j=0;cout<<"输入你要查询的学生姓名:"<<endl;cin>>name;int i=0;for(;i<g;i+)if(strcmp(name,st1i.getname()=0)uj=i;j+;if(j=0)cout<<"没有你所要的学生名字!"/没有找到cout<<"是否退出退出请按 nn"cin>>n;for(int a=0;a<j;a+)/只有一条信息if(j<2) i=ua;cout<<"|缺课日期 |"<<"第几节课 |"<<"课程名称 |"<<"缺课类型|"<<endl;cout<<"|"<<*st1i.gettime()<<"|"<<*(st1i.gettime()+1)<<"|"<<*(st1i.gettime()+2)<<"| "<<st1i.getjieci()<<"| "<<st1i.getkechen()<<"| "<<st1i.getqklx()<<"| "<<endl;/两条信息以上排序elsei=ua;if(*(st1i.gettime()+1)<*(st1i+1.gettime()+1)qti.print(st1i);elseif(*(st1i.gettime()+1)=*(st1i+1.gettime()+1)&&*(st1i.gettime()+2)<*(st1i+1.gettime()+2)qti.print(st1i);elseif(*(st1i.gettime()+1)=*(st1i+1.gettime()+1)&&*(st1i.gettime()+2)=*(st1i+1.gettime()+2)if(strcmp(st1i.getjieci(),st1i+1.getjieci()=-1)qti.print(st1i);cout<<"是否继续查询(y/n)继续请按 y退出按 n"<<endl;cin>>n;/统计某段时间内旷课学生姓名及旷课节数void tongji1(xinxi st1,qstu qt1)int d1=0,js=0;xinxi min;if(g=0)cout<<"没有你要统计的学生信息请返回菜单录入学生缺课信息"<<endl;else if(g=1)cout<<"姓名:"<<st10.getname()<<endl;if(*(st10.getjieci()+2)!='0')js=+2;elsejs+;cout<<"节数:"<<js<<endl;else/信息按时间排序int i=0;for(;i<(g-1);i+)if(*(st1i.gettime()+1)<*(st1i+1.gettime()+1)min=st1i;st1i=st1i+1;st1i+1=st1i;elseif(*(st1i.gettime()+1)=*(st1i+1.gettime()+1)&&*(st1i.gettime()+2)<*(st1i+1.gettime()+2)min=st1i;st1i=st1i+1;st1i+1=st1i;elseif(*(st1i.gettime()+1)=*(st1i+1.gettime()+1)&&*(st1i.gettime()+2)=*(st1i+1.gettime()+2)d1+;for(int j=0;j<(g-d1);j+)cout<<*st1j.gettime()<<*(st1j.gettime()+1)<<*(st1j.gettime()+2)<<endl;for(i=0;i<k;i+) setqstn(st1,qt1,g);cout<<"姓名:"<<qt1i.qstn<<endl;cout<<"节数:"<<qt1i.getjs(st1,g,i)<<endl;/统计某段时间内旷课的课程及旷课人次void tongji2(xinxi st1,qkechen qk1) int d1=0,rc=0;xinxi min;if(g=0)cout<<"没有你要统计的学生信息请返回菜单录入学生缺课信息"<<endl;else if(g=1)cout<<"课程名:"<<st10.getkechen()<<endl;rc+;cout<<"人数:"<<rc<<endl;elseint i=0;for(;i<g;i+)if(*(st1i.gettime()+1)<*(st1i+1.gettime()+1)min=st1i;st1i=st1i+1;st1i+1=st1i;elseif(*(st1i.gettime()+1)=*(st1i+1.gettime()+1)&&*(st1i.gettime()+2)<*(st1i+1.gettime()+2)min=st1i;st1i=st1i+1;st1i+1=st1i;elseif(*(st1i.gettime()+1)=*(st1i+1.gettime()+1)&&*(st1i.gettime()+2)=*(st1i+1.gettime()+2)d1+;for(int j=0;j<(g-d1);j+)cout<<*st1j.gettime()<<*(st1j.gettime()+1)<<*(st1j.gettime()+2)<<endl;for(i=0;i<b;i+) setqkn(st1,qk1,g);cout<<"课程名:"<<qk1i.qkn<<endl;cout<<"人数:"<<qk1i.getrc(st1,g,i)<<endl;void xiansi(xinxi &st1)cout<<"|缺课日期 |"<<"第几节课 |"<<"课程名称 |"<<"学生姓名 |"<<"缺课类型|"<<endl;cout<<"|"<<*(st1.gettime()<<"|"<<*(st1.gettime()+1)<<*(st1.gettime()+2)<<"|"<<st1.getjieci()<<"|"<<st1.getkechen()<<"|"<<st1.getname()<<"|"<<st1.getqklx()<<"|"<<endl;/设置缺课学生名void setqstn(xinxi st1,qstu qt1,int n)int i=0;for(;i<n;i+)if(i=0)strcpy(qt10.qstn,st1i.getname();else if(strcmp(st1i.getname(),st1i+1.getname()!=0)strcpy(qt1i.qstn,st1i.getname();k+;/设置有缺课学生的课程名void setqkn(xinxi st1,qkechen qk,int n)int i=0;for(;i<n;i+)if(i=0)strcpy(qk0.qkn,st1i.getkechen();else if(strcmp(st1i.getkechen(),st1i+1.getkechen()!=0)strcpy(qki.qkn,st1i+1.getkechen();b+;专心-专注-专业