信息科学与技术学院程序设计基础课程设计报告题目名称:学生考勤管理系统学生姓名:郭晨晨学号: 2专业班级: 13级计科(3)班指导教师:郭理2013年6月6日目录目录..............................................1. 课程设计题目与要求.....................................1.1 课题目的和要求....................................1.3 课题意义..........................................2 总体设计................................................2.1功能模块设计 ..........................................2.2系统设计方案 ......................................3 详细设计................................................3.1 数据结构设计.....................................3.2 主模块设计.......................................3.2.1建立学生缺课记录子模块.......................3.2.2修改学生缺课记录子模块.......................3.2.3修改学生缺课记录子模块.......................3.2.4查看单科旷课记录子模块.......................3.2.5查看学生旷课记录子模块.......................3.2.6载入学生旷课记录子模块.......................3.2.7储存学生旷课记录子模快.......................4. 运行结果...............................................4.1运行 ..............................................5. 课程设计总结...........................................结束语....................................................参考文献..................................................附录:源代码..............................................1. 课程设计题目与要求1.1 课题目的和要求设计目的:要求实现---“学生考勤管理程序”记录学生的缺课情况,它包括:缺课日期、第几节课、课程名称、学生姓名、缺课类型(迟到、早退、请假及旷课)。
1.2 设计要求:1.录入学生的缺课记录;2.修改某个学生的缺课记录;3.查询某个学生的缺课情况;4.统计某段时间内,某门课旷课学生姓名及旷课次数,按旷课次数由多到少排序;5.统计某段时间内,有学生旷课的课程及旷课人次,按旷课人次由多到少排序;6.系统以菜单方式工作。
1.3 课题意义程序实践是本科生重要教学环节之一。
通过程序实践,强化学生的计算机应用技能,使学生验证、巩固和充实所学的理论知识,加深对相关内容的理解,拓宽知识面,培养学生的创新精神和实践能力学生考勤管理程序可以大大减缓学生考勤人员的工作量, 方便了平时上课学生的出勤率的管理。
2 总体设计2.1功能模块设计根据分析整个系统主要划分为7个功能模块,分别执行要求中的功能。
数据管理中可以对学生的基本信息、课程的基本信息、学生缺课的查询、添加、删除和修改。
查询管理通过根据学生姓名,课程姓名时间段儿等信息,查询单个学生的缺课记录,单科课的旷课记录,单个学生的旷课记录。
功能模块图如图1所示:图1功能模块图2.2系统设计方案这个程序是过程性语言设计的。
运用多种条件语句,主体采用的是链表指针。
系统的设计采用了数组语句、选择语句和循环语句,在需要处理大量同类数据时,这样就使程序书写更加简洁。
程序使用了布尔函数。
选择语句多采用if多分支选择结构与switch语句。
首先计算switch表达式,然后在caes子句中寻找值相等的常量表达式,并以此为入口符号,由此开始顺序执行。
循环语句采用了for语句等、do-while语句,for语句用于已知循环次数的循环结构,括号中的三个量分别用来表示循环变量初值、循环终值和循环增量。
do-while语句先循环后判断, Break语句在switch语句中,保证多分支情况的正确执行,在循环语句中,强制终止本层循环。
保存和读取函数是典型的函数功能,一个程序是由若干个函数组成的,保存和读取函数是和其他函数互相调用的。
3 详细设计3.1 数据结构设计struct xueke{char xueke_name[50];int people_num;};这是定义了一个xueke结构体,用来存放一个学科名及其相应的旷课人数;struct student{ char name[50];long time;int lesson_time;char lesson_name[50];int chidao_num;int zaotui_num;int qingjia_num;int kuangke_num;struct student *next;};这是定义了一个student的结构体,用来存放一个学生的考勤记录,其中有,字符数组name[50],lesson_name[50],分别存放学生名字,缺课课程名字;int型变量lesson_time,chidao_num,zaotui_num,qingjia_num, kuangke_num,分别来存放,缺课节次,迟到次数,早退次数,请假次数,旷课次数 long型变量time,记录时间。
3.2 主模块设计要建立的学生人数,学生基本信息(包括缺课时间、学生姓名、课程名称、节次、迟到次数、早退次数、请假次数、旷课次数)可用creat()函数如图1.图1根据要修改的学生姓名以及科目名称找到相应的信息,再选择要修改的项目进行单项修改图2 图2根据人名可以查出该学生的所有缺课记录如图3图3根据学科名称和时间范围查出所有在该范围内旷课的学生以及次数如图4图4根据要查询的学科名称及时间段查出在改时间段内该门课上旷课的人数如图5图5可以载入实现储存在当前文件夹中txt文件中所储存的数据如图6图6进入系统界面,顺序的完成各项操作,进行数据的输入,信息的保存调用相应的函数打开相应的地址,查询各项信息。
如图7图74. 运行结果4.1运行开始菜单图1 开始菜单主菜单图2 主菜单建立学生缺课记录图2建立学生缺课记录储存学生旷课记录图3储存学生旷课记录5. 课程设计总结课程设计顺利完成,题目所要求的功能基本实现,可以对学生的缺课信息进行添加,修改,删除以及查询的显示。
不过这个程序还不够完善,例如不能往当前文件夹中的txt文件中添加记录。
结束语整个系统的设计过程对于我来说是个学习、探索的过程,通过借鉴别人,学习设计程序,在整个设计过程中,出现过很多的问题,很多繁琐的东西都需要反复的修改,主要是因为前期的学习不认真,对系统的需求分析的要求认识不清楚,使得在后边的工作中不得不经常反复请教别人去修改。
使我体会到设置中每一步的重要性。
所以在分析一个问题时,我们需要站在一个有远见的高度。
通过此次设计,我对C++语言编程有了深刻的认识,积累了使用软件工程的思想来开发软件的经验,更重要的是学会了在对待问题时应该考虑到哪些方面和怎么解决问题。
虽然时间紧迫但我学会了不少,感到自身知识的贫乏,希望在日后积极学习并尝试努力中能做出完善的系统。
参考文献谭浩强.C++语言程序设计.清华大学出版社求是科技.Visual C++ 6.0信息系统开发.人民邮电出版社附录:源代码#include<cstdio> //cstdio是将stdio.h的内容用C++头文件的形式表示出来#include<iostream>要用到动态的分配内存。
#include<cstring> //当调用库函数,客户程序提供的是string类型参数,而库函数内部实现用的是c-串,因此需要将string对象,转化为char*对象,而c_str()提供了这样一种方法,它返回一个客户程序可读不可改的指向字符数组的指针。
#include<iomanip> //I/O流控制头文件#define NULL 0#define guding 10#define LEN sizeof(struct student)using namespace std;int student_num;FILE *fp1;struct xueke{char xueke_name[50];int people_num;};struct student{ char name[50];long time;int lesson_time;char lesson_name[50];int chidao_num;int zaotui_num;int qingjia_num;int kuangke_num;struct student *next;};void chaxun(struct student *head){ int i;char chaxun_name[50];cout<<"请输入要查询的人名:";cin>>chaxun_name;struct student *p;if(head==NULL)cout<<"联系人为空";p=head;for(i=0;i<student_num;i++){if(strcmp(chaxun_name,p->name)==0){cout<<"缺课时间:"<<p->time<<" 学生姓名:"<<p->name<<" 课程名称:"<<p->lesson_name<<" 节次:"<<p->lesson_time<<endl<<"迟到次数:"<<p->chidao_num<<" 早退次数:"<<p->zaotui_num<<" 请假次数:"<<p->qingjia_num<<" 旷课次数:"<<p->kuangke_num<<endl;}p=p->next; }}struct student *xiugai(struct student *head){char xiugai_name[50];char xiugai_xueke_name[50];int k;cout<<"请输入要修改的学生姓名与学科名称【格式:学生姓名(空格)学科名称】:";cin>>xiugai_name>>xiugai_xueke_name;struct student *p1,*p2;p2=(struct student *)malloc(LEN);p1=head;if(head==NULL){cout<<"没有学生信息\n";return head; }while((strcmp(xiugai_name,p1->name)!=0||strcmp(xiugai_xueke_name,p1->less on_name)!=0)&&(p1->next!=NULL))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\n";cout<<"================================================================== ==============\n";cin>>k;switch(k){case 1:cout<<"请输入新的缺课时间:";cin>>p1->time;break;case 2:cout<<"请输入新的学生姓名:";cin>>p1->name;break;case 3:cout<<"请输入新的课程名称:";cin>>p1->lesson_name;break;case 4:cout<<"请输入新的缺课节次:";cin>>p1->lesson_time;break;case 5:cout<<"请输入新的迟到次数:";cin>>p1->chidao_num;break;case 6:cout<<"请输入新的早退次数:";cin>>p1->zaotui_num;break;case 7:cout<<"请输入新的请假次数:";cin>>p1->qingjia_num;break;case 8:cout<<"请输入新的旷课次数:";cin>>p1->kuangke_num;break; }}return head;}struct student *creat(){int i,b;struct student *head,*p1,*p2;cout<<"请输入要建立资料的学生人数:";cin>>b;head=p2=NULL;p1=(struct student *)malloc(LEN);cout<<"【输入格式:缺课时间(空格)学生姓名(空格)课程名称(空格)第几节(空格)迟到次数(空格)早退次数(空格)请假次数(空格)旷课次数】\n";cout<<"请输入第1名学生信息:";cin>>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+=1;for(i=1;i<b;i++){p1=(struct student*)malloc(LEN);cout<<"请输入第"<<i+1<<"名学生信息:";cin>>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+=1;}p2->next=NULL;return head;}void print(struct student *head){struct student *p;p=head;if(p==NULL)cout<<"没有学生信息\n";while(p!=NULL){ cout<<"缺课时间:"<<p->time<<" 学生姓名:"<<setw(10)<<p->name<<"课程名称:"<<p->lesson_name<<" 节次:"<<p->lesson_time<<endl <<"迟到次数:"<<p->chidao_num<<" 早退次数:"<<p->zaotui_num<<" 请假次数:"<<p->qingjia_num<<" 旷课次数:"<<p->kuangke_num<<endl;p=p->next;}}struct student *tongji_lesson(struct student *head){ struct student *p1,*p2,*p3;char lesson[50];long look_time1,look_time2;int xunhuan_num=0;p3=(struct student *)malloc(LEN);if(head==NULL){cout<<"没有学生信息";return(head); }p1=head;p2=p1->next;while(xunhuan_num<student_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>>lesson;cout<<"请输入要查看的时间范围【输入格式:时间(空格)时间】";cin>>look_time1>>look_time2;p1=head;while(p1!=NULL){if(strcmp(lesson,p1->lesson_name)==0&&look_time1<=p1->time&&p1->time<=lo ok_time2)cout<<"学生姓名:"<<p1->name<<" 旷课次数:"<<p1->kuangke_num<<endl;p1=p1->next; }return head;}struct student *tongji_student(struct student *head){ struct xueke a[10];int n,i,j,zhongjian;struct student *p1;char zhongjian_name[50];long look_time1,look_time2;if(head==NULL){cout<<"没有学生信息\n";return head;}cout<<"请输入一共的学科数:";cin>>n;for(i=0;i<n;i++){cout<<"请输入第"<<i+1<<"个学科名称:";cin>>a[i].xueke_name;a[i].people_num=0;}cout<<"请输入要查看的时间范围由小到大【输入格式:时间(空格)时间】";cin>>look_time1>>look_time2;p1=head;for(i=0;i<n;i++){while(p1!=NULL&&look_time1<=p1->time&&p1->time<=look_time2) {if(a[i].xueke_name==p1->lesson_name)a[i].people_num+=p1->kuangke_num;p1=p1->next;}p1=head;}for(j=0;j<n-1;j++)for(i=0;i<n-1-j;i++){if(a[i].people_num<a[i+1].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);}elseif(a[i].people_num==a[i+1].people_num&&strcmp(a[i].xueke_name,a[i+1].xueke_n ame)>0){ 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<n;i++){cout<<"学科名称:"<<a[i].xueke_name<<" 旷课次数:"<<a[i].people_num<<endl;return head;}return head;}struct student *zairu(){struct student *p1=NULL,*p2=NULL,*head=NULL;struct student student_ziliao[100];int i=0,n=0;if((fp1=fopen("xueshengziliao.txt","rb+"))==NULL){ printf("cannot open file\n");return(head); }while(!feof(fp1)){if(fread(&student_ziliao[i],LEN,1,fp1)!=1){if(feof(fp1)){fclose(fp1);break; }printf("file read error\n");}i++;}n=i;student_num=n;p1=p2=(struct student *)malloc(LEN);head=p1;for(i=0;i<n;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=(struct student*)malloc(LEN); }p2->next=NULL;return(head);}void chucun(struct student *head){ struct student *p1;p1=head;fp1=fopen("xueshengziliao.txt","wb+");while(p1!=NULL){fwrite(p1,LEN,1,fp1);p1=p1->next; }fclose(fp1);cout<<" 储存成功\n";}void main(){struct student *head;int a,b,c;zhuye: cout<<"$$$$$$$$$$$$$$$$$$$$$$ 欢迎使用学生考勤管理系统 V1.0.0 $$$$$$$$$$$$$$$$$$\n";cout<<" 1_进入管理\n\n\n";cout<<" 2_查看系统相关信息\n\n\n";cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$\n\n\n\n\n";cin>>a;if(a==1){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>>b;switch(b){case 1:head=creat();print(head);break;case 2:head=xiugai(head);print(head);break;case 3:chaxun(head);break;case 4:head=tongji_lesson(head);break;case 5:head=tongji_student(head);break;case 6:head=zairu();print(head);break;case 7:chucun(head);break;}}while(b!=8);}else{cout<<"******************************欢迎使用本系统**************************************\n";cout<<"******************************返回主页请按1*************************************\n";cin>>c;if(c==1)goto zhuye;} }。