学生考勤管理系统报告2.docx
《学生考勤管理系统报告2.docx》由会员分享,可在线阅读,更多相关《学生考勤管理系统报告2.docx(29页珍藏版)》请在冰豆网上搜索。
![学生考勤管理系统报告2.docx](https://file1.bdocx.com/fileroot1/2022-11/27/92305526-dc38-41ee-8209-28dde854bc62/92305526-dc38-41ee-8209-28dde854bc621.gif)
学生考勤管理系统报告2
学生考勤管理系统
根据分析整个系统主要划分为7个功能模块,分别执行要求中的功能。
数据管理中实现对学生的基本信息、课程的基本信息、学生缺课的查询、添加、删除和修改,以及具体缺课缺课内容,是迟到、早退、请假、旷课。
查询管理通过根据学生姓名,课程姓名时间段儿等信息,查询单个学生的缺课记录,单科课的旷课记录,单个学生的旷课记录。
功能模块图如图1所示。
、
图1功能模块图
[1]
[2]
[3]
[4]
图1主菜单
1.建立学生缺课记录
图2建立学生缺课记录
2.修改学生缺课记录
图3修改学生缺课记录
3.查询学生缺课记录
图4查询学生缺课记录
4.查看单科旷课记录
图5查看单科旷课记录
5.查看学生旷课记录
图6查看学生旷课记录
6.储存学生旷课记录
图7储存学生旷课记录
7.载入学生旷课记录
图8载入学生旷课记录
8.退出程序
图9退出程序
附录2—源程序
#include
#include
#include
#defineNULL0
#defineLENsizeof(structstudent)
intstudent_num;
FILE*fp1;
structxueke
{unsignedcharxueke_name[50];
intpeople_num;
};
structxuekea[10];
structstudent
{unsignedcharname[50];
longtime;
intlesson_time;
unsignedcharlesson_name[50];
intchidao_num;
intzaotui_num;
intqingjia_num;
intkuangke_num;
structstudent*next;
};
voidchaxun(structstudent*head)
{inti;
unsignedcharchaxun_name[50];
cout<<"请输入要查询的人名【若没有这个人则不显示】:
"<cin>>"%s",chaxun_name;
structstudent*p;
if(head==NULL)
cout<<"联系人为空"<p=head;
for(i=0;i{if(strcmp(chaxun_name,p->name)==0)
cout<<"缺课时间:
%ld学生姓名:
%s课程名称:
%s第%d节迟到次数:
%d早退次数:
%d请假次数:
%d旷课次数:
%d\n",p->time,p->name,p->lesson_name,p->lesson_time,p->chidao_num,p->zaotui_num,p->qingjia_num,p->kuangke_num<p=p->next;}
}
structstudent*xiugai(structstudent*head)
{unsignedcharxiugai_name[50];
unsignedcharxiugai_xueke_name[50];
intk;
cout<<"请输入要修改的学生姓名与学科名称【格式:
学生姓名(空格)学科名称】:
"<cin>>"%s%s",xiugai_name,xiugai_xueke_name;
structstudent*p1,*p2;
p2=(structstudent*)malloc(LEN);
p1=head;
if(head==NULL)
{cout<<"没有学生信息\n"<return(head);}
while(strcmp(xiugai_name,p1->name)!
=0&&(p1->next!
=NULL)&&strcmp(xiugai_xueke_name,p1->lesson_name)!
=0)
p1=p1->next;
if(strcmp(xiugai_name,p1->name)==0&&strcmp(xiugai_xueke_name,p1->lesson_name)==0)
{cout<<"=======================================\n"<cout<<"1-修改缺课时间\n"<cout<<"2-修改学生姓名\n"<cout<<"3-修改课程名称\n"<cout<<"4-修改第几节缺课\n"<cout<<"5-修改迟到次数\n"<cout<<"6-修改早退次数\n"<cout<<"7-修改请假次数\n"<cout<<"8-修改旷课次数\n"<cout<<"=======================================\n"<cin>>"%d",&k;
switch(k)
{case1:
cout<<"请输入新的缺课时间"<cin>>"%ld",&p1->time;
break;
case2:
cout<<"请输入新的学生姓名"<cin>>"%s",p1->name;
break;
case3:
cout<<"请输入新的课程名称"<cin>>"%s",p1->lesson_name;
break;
case4:
cout<<"请输入新的第几节缺课"<cin>>"%d",&p1->lesson_time;
break;
case5:
cout<<"请输入新的迟到次数"<cin>>"%d",&p1->chidao_num;
break;
case6:
cout<<"请输入新的早退次数"<cin>>"%d",&p1->zaotui_num;
break;
case7:
cout<<"请输入新的请假次数"<cin>>"%d",&p1->qingjia_num;
break;
case8:
cout<<"请输入新的旷课次数"<cin>>"%d",&p1->kuangke_num;
break;}
}
return(head);
}
structstudent*creat()
{
inti,b;
structstudent*head,*p1,*p2;
cout<<"请输入要建立资料的学生人数:
"<cin>>"%d",&b;
head=p2=NULL;
p1=(structstudent*)malloc(LEN);
cout<<"【输入格式:
缺课时间(空格)学生姓名(空格)课程名称(空格)第几节(空格)迟到次数(空格)早退次数(空格)请假次数(空格)旷课次数】\n"<cout<<"请输入第1名学生信息:
"<cin>>"%ld%s%s%d%d%d%d%d",&p1->time,p1->name,p1->lesson_name,&p1->lesson_time,&p1->chidao_num,&p1->zaotui_num,&p1->qingjia_num,&p1->kuangke_num;
head=p1;
p2=p1;
student_num++;
for(i=1;i
{
p1=(structstudent*)malloc(LEN);
cout<<"请输入第%d名学生信息:
",i+1<cin>>"%ld%s%s%d%d%d%d%d",&p1->time,p1->name,p1->lesson_name,&p1->lesson_time,&p1->chidao_num,&p1->zaotui_num,&p1->qingjia_num,&p1->kuangke_num;
p2->next=p1;
p2=p1;
student_num++;
}
p2->next=NULL;
return(head);
}
voidprint(structstudent*head)
{structstudent*p;
p=head;
if(p==NULL)
cout<<"没有学生信息\n"<while(p!
=NULL)
{cout<<"缺课时间:
%ld学生姓名:
%s课程名称:
%s第%d节迟到次数:
%d早退次数:
%d请假次数:
%d旷课次数:
%d\n",p->time,p->name,p->lesson_name,p->lesson_time,p->chidao_num,p->zaotui_num,p->qingjia_num,p->kuangke_num<p=p->next;}
}
structstudent*tongji_lesson(structstudent*head)
{structstudent*p1,*p2,*p3;
unsignedcharlesson[50];
longlook_time1,look_time2;
intxunhuan_num=0;
p3=(structstudent*)malloc(LEN);
if(head==NULL)
{cout<<"没有学生信息"<return(head);}
p1=head;
p2=p1->next;
while(xunhuan_num{while(p2!
=NULL)
{
if(p2->kuangke_num>p1->kuangke_num)
{
p3->chidao_num=p2->chidao_num;
p3->kuangke_num=p2->kuangke_num;
p3->qingjia_num=p2->qingjia_num;
p3->zaotui_num=p2->zaotui_num;
p3->lesson_time=p2->lesson_time;
p3->time=p2->time;
strcpy(p3->lesson_name,p2->lesson_name);
strcpy(p3->name,p2->name);
p2->chidao_num=p1->chidao_num;
p2->kuangke_num=p1->kuangke_num;
p2->qingjia_num=p1->qingjia_num;
p2->zaotui_num=p1->zaotui_num;
p2->lesson_time=p1->lesson_time;
p2->time=p1->time;
strcpy(p2->lesson_name,p1->lesson_name);
strcpy(p2->name,p1->name);
p1->chidao_num=p3->chidao_num;
p1->kuangke_num=p3->kuangke_num;
p1->qingjia_num=p3->qingjia_num;
p1->zaotui_num=p3->zaotui_num;
p1->lesson_time=p3->lesson_time;
p1->time=p3->time;
strcpy(p1->lesson_name,p3->lesson_name);
strcpy(p1->name,p3->name);
}
p1=p2;
p2=p2->next;
}
p1=head;
p2=p1->next;
xunhuan_num++;
}
cout<<"请输入要查看的学科名称:
"<cin>>"%s",lesson;
cout<<"请输入要查看的时间范围【输入格式:
时间(空格)时间】"<cin>>"%ld%ld",&look_time1,&look_time2;
p1=head;
while(p1!
=NULL)
{if(strcmp(lesson,p1->lesson_name)==0&&look_time1<=p1->time&&p1->time<=look_time2)
cout<<"学生姓名%s旷课次数%d\n",p1->name,p1->kuangke_num<p1=p1->next;}
return(head);
}
structstudent*tongji_student(structstudent*head)
{
intn,i,j,zhongjian;
structstudent*p1;
unsignedcharzhongjian_name[50];
longlook_time1,look_time2;
if(head==NULL)
{cout<<"没有学生信息"<return(head);}
cout<<"请输入一共的学科数:
"<cin>>"%d",&n;
for(i=0;i{cout<<"请输入第%d个学科名称:
",i+1<cin>>"%s",a[i].xueke_name;
a[i].people_num=0;}
cout<<"请输入要查看的时间范围由小到大【输入格式:
时间(空格)时间】"<cin>>"%ld%ld",&look_time1,&look_time2;
p1=head;
for(i=0;i{while(p1!
=NULL&&look_time1<=p1->time&&p1->time<=look_time2)
{if(strcmp(a[i].xueke_name,p1->lesson_name)==0)
a[i].people_num+=p1->kuangke_num;
p1=p1->next;}
p1=head;}
for(j=0;jfor(i=0;i{if(a[i].people_num{zhongjian=a[i+1].people_num;
a[i+1].people_num=a[i].people_num;
a[i].people_num=zhongjian;
strcpy(zhongjian_name,a[i+1].xueke_name);
strcpy(a[i+1].xueke_name,a[i].xueke_name);
strcpy(a[i].xueke_name,zhongjian_name);}
}
for(i=0;i{cout<<"学科名称%s旷课人%d\n",a[i].xueke_name,a[i].people_num<return(head);}
}
structstudent*zairu()
{structstudent*p1=NULL,*p2=NULL,*head=NULL;
structstudentstudent_ziliao[100];
inti=0,n=0;
if((fp1=fopen("xueshengziliao.txt","rb+"))==NULL)
{cout<<"cannotopenfile\n"<return(head);}
while(!
feof(fp1))
{if(fread(&student_ziliao[i],LEN,1,fp1)!
=1)
{if(feof(fp1))
{fclose(fp1);
break;}
cout<<"filereaderror\n"<i++;
}
n=i;
p1=p2=(structstudent*)malloc(LEN);
head=p1;
for(i=0;i{p1->chidao_num=student_ziliao[i].chidao_num;
p1->kuangke_num=student_ziliao[i].kuangke_num;
strcpy(p1->lesson_name,student_ziliao[i].lesson_name);
p1->lesson_time=student_ziliao[i].lesson_time;
strcpy(p1->name,student_ziliao[i].name);
p1->qingjia_num=student_ziliao[i].qingjia_num;
p1->time=student_ziliao[i].time;
p1->zaotui_num=student_ziliao[i].zaotui_num;
p2->next=p1;
p2=p1;
p1=(structstudent*)malloc(LEN);}
p2->next=NULL;
return(head);
}
voidchucun(structstudent*head)
{structstudent*p1;
p1=head;
fp1=fopen("xueshengziliao.txt","wb+");
while(p1!
=NULL)
{fwrite(p1,LEN,1,fp1);
p1=p1->next;}
fclose(fp1);
cout<<"储存成功\n"<}
voidmain()
{
structstudent*head;
intm;
do
{
cout<<"***************************************************\n"<cout<<"1_建立学生缺课记录\n"<cout<<"2_修改学生缺课记录\n"<cout<<"3_查询学生缺课记录\n"<cout<<"4_查看单科旷课记录\n"<cout<<"5_查看学生旷课记录\n"<cout<<"6_载入学生旷课记录\n"<cout<<"7_储存学生旷课记录\n"<cout<<"8_退出考勤管理程序\n"<cout<<"***************************************************\n"<cin>>"%d",&m;
switch(m)
{
case1:
head=creat();
print(head);
break;
case2:
head=xiugai(head);
print(head);
break;
case3:
chaxun(head);
break;
case4:
head=tongji_lesson(head);
break;
case5:
head=tongji_student(head);
break;
case6:
head=zairu();print(head);
break;
case7:
chucun(head);
break;
}
}while(m!
=8);