学生考勤管理系统源代码教程文件.docx
《学生考勤管理系统源代码教程文件.docx》由会员分享,可在线阅读,更多相关《学生考勤管理系统源代码教程文件.docx(14页珍藏版)》请在冰豆网上搜索。
![学生考勤管理系统源代码教程文件.docx](https://file1.bdocx.com/fileroot1/2023-1/26/a430584d-28b0-4261-a8e5-09c81c17b818/a430584d-28b0-4261-a8e5-09c81c17b8181.gif)
学生考勤管理系统源代码教程文件
#include
#include
#include
usingnamespacestd;
classtime
{public:
time(inty=0,intm=0,intd=0)
{year=y;month=m;day=d;}
~time(){}
protected:
intyear,month,day;
};
//信息类
classxinxi:
publictime
{public:
xinxi(){tiaoshu++;}
~xinxi(){tiaoshu--;}
voidsetname(char*n){strcpy(name,n);}
voidsettime(inty,intm,intd){year=y;month=m;day=d;}
voidsetqklx(char*qk){strcpy(queke,qk);}
voidsetjieci(char*jc){strcpy(jieci,jc);}
voidsetkechen(char*kc){strcpy(kechen,kc);}
char*getname(){char*n;n=name;returnn;}
char*getqklx(){char*qk=queke;returnqk;}
char*getjieci(){char*jc;jc=jieci;returnjc;}
char*getkechen(){char*gk;gk=kechen;returngk;}
int*gettime();
private:
charname[20];//姓名
charjieci[3],kechen[10],queke[10];
inttm[3];
staticinttiaoshu;
};
intxinxi:
:
tiaoshu=0;
int*xinxi:
:
gettime()
{
int*t;
t=tm;
tm[0]=year;
tm[1]=month;
tm[2]=day;
returnt;
}
classqkechen:
publicxinxi
{public:
qkechen(){kcshu++;}
~qkechen(){kcshu--;}
intgetrc(xinxist1[],intn,intj);
charqkn[20];//公有数据成员
private:
intrenci;
staticintkcshu;//静态数据成员
};
intqkechen:
:
kcshu=0;
intqkechen:
:
getrc(xinxist1[],intn,intj)
{
renci=0;
renci++;
for(inti=0;iif(*(st1[i+1].gettime()+1)==*(st1[j].gettime()+1)&&*(st1[i+1].gettime()+2)==
*(st1[j].gettime()+2))
if(strcmp(qkn,st1[i].getkechen())==0)
renci++;
returnrenci;
}
classqstu:
publicxinxi
{public:
qstu(){qst++;}
~qstu(){qst--;}
voidprint(xinxi&st1);
intgetjs(xinxist1[],intn,intj);
intsetjs(intjs=0)
{jieshu=js;}
charqstn[20];
private:
intjieshu;
staticintqst;//静态数据成员
};
intqstu:
:
qst=0;
voidqstu:
:
print(xinxi&st1)
{
cout<<"|缺课日期|"<<"第几节课|"<<"课程名称|"<<"缺课类型|"<cout<<"|"<<*st1.gettime()<<"|"<<*(st1.gettime()+1)<<*(st1.gettime()+2)<<"|"<<}
intqstu:
:
getjs(xinxist1[],intn,intj)
{
inti=0,js=0;
xinximin;
if(*(st1[j].getjieci()+2)!
='\0')
js=+2;
else
js++;
for(i=0;iif(*(st1[i+1].gettime()+1)==*(st1[j].gettime()+1)&&*(st1[i+1].gettime()+2)==*(st1[j].gettime()+2))
if(strcmp(st1[i+1].getname(),qstn)==0)
{
if(*(st1[i].getjieci()+2)!
='\0')
js=+2;
else
js++;
}
jieshu=js;
returnjieshu;
}
//函数声明
intshuru(xinxist1[]);
voidchaxun(xinxist1[],qstuqt[]);
voidxiugai(xinxist1[],intn);
voidtongji1(xinxist1[],qstuqt1[]);
voidtongji2(xinxist1[],qkechenqk1[]);
voidcaidan();
voidxiansi(xinxi&st1);
voidsetqstn(xinxist1[],qstuqt1[],intn);
voidsetqkn(xinxist1[],qkechenqk[],intn);
//全局变量
intg,k=1,b=1;
intq=-1;
charname[20],kechen[10],queke[10],jieci[3];
inty,m,d;
//主函数
intmain()
{
xinxitl[15];//定义15条信息类对象
qstuqt[10];
qkechenqk[6];
intch;
while
(1)
{cout<<"********欢迎进入学生考勤管理系统!
*********"<caidan();
cout<<"--------请选择菜单项:
"<cin>>ch;
switch(ch)
{case1:
g=shuru(tl);break;
case2:
xiugai(tl,g);break;
case3:
chaxun(tl,qt);break;
case4:
tongji1(tl,qt);break;
case5:
tongji2(tl,qk);break;
case6:
exit(0);
}
}
return0;
}
voidcaidan()
{system("colorA");
cout<<"*************************************************************"<cout<<"*学生考勤管理系统*"<cout<<"*************************************************************"<cout<<"1.-------------录入学生的缺课记录---------------------------*"<cout<<"3.-------------查询学生的缺课情况---------------------------*"<cout<<"4.--------统计某段时间内旷课学生姓名及旷课节数--------------*"<cout<<"5.--------统计某段时间内旷课的课程及旷课人次----------------*"<cout<<"6.----------------退出系统----------------------------------*"<}
//输入函数
intshuru(xinxist1[])
{chara;
cout<<"------输入开始!
----"<do{q++;
cout<<"请输入学生姓名"<cin>>name;
st1[q].setname(name);
cout<<"请输入课程名称"<cin>>kechen;
st1[q].setkechen(kechen);
cout<<"请输入缺课日期"<cin>>y>>m>>d;
st1[q].settime(y,m,d);
cout<<"请输入缺课类型"<cin>>queke;
st1[q].setqklx(queke);
cout<<"请输入缺课节次"<cin>>jieci;
st1[q].setjieci(jieci);
cout<<"是否还要继续输入:
(y/n)"<cin>>a;
}while(a=='y');
returnq+1;
}
voidxiugai(xinxist1[],intn)
{
intk=1,j=0,a[10];
intflgh;
inth;
while(k==1)
{cout<<"请输入你要修改缺课记录的学生姓名"<cin>>name;
flgh=0;
for(inti=0;iif(strcmp(name,st1[i].getname())==0)
do{a[j]=i;
cout<<"1.修改日期2.修改节次3.修改课程名称4.修改缺课类型"<cout<<"请输入要选择的数值(1,2,3,4)"<intb;
cin>>b;
if(b==1)
{cout<<"请输入新日期"<cin>>y>>m>>d;
st1[i].settime(y,m,d);
}
elseif(b==2)
{cout<<"请输入新节次"<cin>>jieci;
st1[i].setjieci(jieci);
}
elseif(b==3)
{cout<<"请输入新课程名称"<cin>>kechen;
st1[i].setkechen(kechen);
}
elseif(b==4)
{cout<<"请输入新缺课类型"<cin>>queke;
st1[i].setqklx(queke);
}
flgh=1;j++;
}while(b<1||b>4);
if(flgh==0)
{cout<<"没有你要找的学生姓名,请重试要退出请按0"<cin>>k;
}
else
{cout<<"还要继续吗(1\0)退出请按0"<cin>>k;
}
}
for(inti=0;i{
h=a[i];
xiansi(st1[h]);
}
}
voidchaxun(xinxist1[],qstuqt[])
{
charn='y';
intu[10];
while(n=='y')
{
intj=0;
cout<<"输入你要查询的学生姓名:
"<cin>>name;
inti=0;
for(;iif(strcmp(name,st1[i].getname())==0)
{
u[j]=i;
j++;
}
if(j==0)
{
cout<<"没有你所要的学生名字!
";//没有找到
cout<<"是否退出退出请按n\n";
cin>>n;
}
for(inta=0;a{
//只有一条信息
if(j<2)
{i=u[a];
cout<<"|缺课日期|"<<"第几节课|"<<"课程名称|"<<"缺课类型|"<cout<<"|"<<*st1[i].gettime()<<"|"<<*(st1[i].gettime()+1)<<"|"<<*(st1[i].gettime()+2)<<"|"<}
//两条信息以上排序
else
{
i=u[a];
if(*(st1[i].gettime()+1)<*(st1[i+1].gettime()+1))
qt[i].print(st1[i]);
else
if(*(st1[i].gettime()+1)==*(st1[i+1].gettime()+1)&&*(st1[i].gettime()+2)<*(st1[i+1].gettime()+2))
qt[i].print(st1[i]);
else
if(*(st1[i].gettime()+1)==*(st1[i+1].gettime()+1)&&*(st1[i].gettime()+2)==*(st1[i+1].gettime()+2))
if(strcmp(st1[i].getjieci(),st1[i+1].getjieci())==-1)
qt[i].print(st1[i]);
}
cout<<"是否继续查询(y/n)继续请按y退出按n"<cin>>n;
}
}
}
//统计某段时间内旷课学生姓名及旷课节数
voidtongji1(xinxist1[],qstuqt1[])
{
intd1=0,js=0;
xinximin;
if(g==0)
cout<<"没有你要统计的学生信息请返回菜单录入学生缺课信息"<elseif(g==1)
{
cout<<"姓名:
"<if(*(st1[0].getjieci()+2)!
='\0')
js=+2;
else
js++;
cout<<"节数:
"<}
else
//信息按时间排序
{inti=0;
for(;i<(g-1);i++)
{
if(*(st1[i].gettime()+1)<*(st1[i+1].gettime()+1))
{min=st1[i];st1[i]=st1[i+1];st1[i+1]=st1[i];}
else
if(*(st1[i].gettime()+1)==*(st1[i+1].gettime()+1)&&*(st1[i].gettime()+2)<*(st1[i+1].gettime()+2))
{min=st1[i];st1[i]=st1[i+1];st1[i+1]=st1[i];}
else
if(*(st1[i].gettime()+1)==*(st1[i+1].gettime()+1)&&*(st1[i].gettime()+2)==*(st1[i+1].gettime()+2))
d1++;
}
for(intj=0;j<(g-d1);j++)
{
cout<<*st1[j].gettime()<<*(st1[j].gettime()+1)<<*(st1[j].gettime()+2)<for(i=0;i{setqstn(st1,qt1,g);
cout<<"姓名:
"<cout<<"节数:
"<}
}
}
}
//统计某段时间内旷课的课程及旷课人次
voidtongji2(xinxist1[],qkechenqk1[])
{intd1=0,rc=0;
xinximin;
if(g==0)
cout<<"没有你要统计的学生信息请返回菜单录入学生缺课信息"<elseif(g==1)
{
cout<<"课程名:
"<rc++;
cout<<"人数:
"<}
else
{
inti=0;
for(;i{
if(*(st1[i].gettime()+1)<*(st1[i+1].gettime()+1))
{min=st1[i];st1[i]=st1[i+1];st1[i+1]=st1[i];}
else
if(*(st1[i].gettime()+1)==*(st1[i+1].gettime()+1)&&*(st1[i].gettime()+2)<*(st1[i+1].gettime()+2))
{min=st1[i];st1[i]=st1[i+1];st1[i+1]=st1[i];}
else
if(*(st1[i].gettime()+1)==*(st1[i+1].gettime()+1)&&*(st1[i].gettime()+2)==*(st1[i+1].gettime()+2))
d1++;
}
for(intj=0;j<(g-d1);j++)
{
cout<<*st1[j].gettime()<<*(st1[j].gettime()+1)<<*(st1[j].gettime()+2)<for(i=0;i
{setqkn(st1,qk1,g);
cout<<"课程名:
"<cout<<"人数:
"<}
}
}
}
voidxiansi(xinxi&st1)
{
cout<<"|缺课日期|"<<"第几节课|"<<"课程名称|"<<"学生姓名|"<<"缺课类型|"<cout<<"|"<<*(st1.gettime())<<"|"<<*(st1.gettime()+1)<<*(st1.gettime()+2)
<<"|"<}
//设置缺课学生名
voidsetqstn(xinxist1[],qstuqt1[],intn)
{
inti=0;
for(;i{if(i==0)
strcpy(qt1[0].qstn,st1[i].getname());
elseif(strcmp(st1[i].getname(),st1[i+1].getname())!
=0)
{strcpy(qt1[i].qstn,st1[i].getname());
k++;
}
}
}
//设置有缺课学生的课程名
voidsetqkn(xinxist1[],qkechenqk[],intn)
{
inti=0;
for(;i{
if(i==0)
strcpy(qk[0].qkn,st1[i].getkechen());
elseif(strcmp(st1[i].getkechen(),st1[i+1].getkechen())!
=0)
{strcpy(qk[i].qkn,st1[i+1].getkechen());
b++;
}
}
}