|
|
|
@ -0,0 +1,370 @@
|
|
|
|
|
#include"stdio.h"
|
|
|
|
|
#include"string.h"
|
|
|
|
|
#define N 100
|
|
|
|
|
#define NULL 0
|
|
|
|
|
int n,m=0;//n为记录学生的个数;m为统计函数1中记录符合统计条件的个数
|
|
|
|
|
struct kuangke
|
|
|
|
|
{//有关旷课统计函数1的信息记录
|
|
|
|
|
char name[40];
|
|
|
|
|
int kuangke_num;
|
|
|
|
|
}kuangke[N];
|
|
|
|
|
struct kuangke2
|
|
|
|
|
{//有关旷课统计函数2的信息记录
|
|
|
|
|
char name[40];
|
|
|
|
|
int num;
|
|
|
|
|
}kuangke2[N];
|
|
|
|
|
struct kuangke temp;//旷课信息交换
|
|
|
|
|
struct kuangke2 temp2;//旷课信息交换
|
|
|
|
|
struct Student
|
|
|
|
|
{//
|
|
|
|
|
int num;
|
|
|
|
|
char name[40];
|
|
|
|
|
char lesson_name[40];
|
|
|
|
|
char lesson_time[40];
|
|
|
|
|
float time;
|
|
|
|
|
int chidao_num;
|
|
|
|
|
int zaotui_num;
|
|
|
|
|
int qingjia_num;
|
|
|
|
|
int kuangke_num;
|
|
|
|
|
}stu[N];
|
|
|
|
|
void creat(void)
|
|
|
|
|
{//创建学生缺课记录
|
|
|
|
|
int i;
|
|
|
|
|
printf("\n请输入需要创建缺课信息的总学生数:\n");
|
|
|
|
|
scanf("%d",&n);
|
|
|
|
|
printf("\n请输入缺课学生信息 包括:\n");
|
|
|
|
|
printf("学号 姓名 课程名称 上课时间 缺课日期 迟到次数 早退次数 请假次数 旷课次数 \n");
|
|
|
|
|
printf("例如:\n08 张三丰 C语言课程设计 三、四节 6.10 \t1 \t0 \t0 \t0\n\n");
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
printf("\n请输入第%d位同学信息:\n",i+1);
|
|
|
|
|
scanf("%d%s%s%s%f%d%d%d%d",&stu[i].num,stu[i].name,stu[i].lesson_name,stu[i].lesson_time,&stu[i].time,&stu[i].chidao_num,&stu[i].zaotui_num,&stu[i].qingjia_num,&stu[i].kuangke_num);
|
|
|
|
|
printf("\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
|
|
printf("第%d位同学信息为:\n\n",i+1);
|
|
|
|
|
printf("\t学号\t姓名\t课程名称\n");
|
|
|
|
|
printf("\t%d\t%s\t%s\n\n",stu[i].num,stu[i].name,stu[i].lesson_name);
|
|
|
|
|
printf("\t上课时间\t缺课日期\n");
|
|
|
|
|
printf("\t%s\t%0.2f\n\n",stu[i].lesson_time,stu[i].time);
|
|
|
|
|
printf("\t迟到次数 早退次数 请假次数 旷课次数\n");
|
|
|
|
|
printf("\t%d\t\t%d\t%d\t\t%d\n\n",stu[i].chidao_num,stu[i].zaotui_num,stu[i].qingjia_num,stu[i].kuangke_num);
|
|
|
|
|
printf("\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
void xiugai(void)
|
|
|
|
|
{//修改学生缺课记录
|
|
|
|
|
int i,k,flag=0;
|
|
|
|
|
int num;
|
|
|
|
|
printf("\n请输入需要修改信息的学号\n");
|
|
|
|
|
scanf("%d",&num);
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{//检测是否有符合的数据;
|
|
|
|
|
if(num==stu[i].num)
|
|
|
|
|
{
|
|
|
|
|
printf("\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
|
|
printf("%d号学生的信息为:\n\n",num);
|
|
|
|
|
printf("\t学号\t姓名\t课程名称\n");
|
|
|
|
|
printf("\t%d\t%s\t%s\n\n",stu[i].num,stu[i].name,stu[i].lesson_name);
|
|
|
|
|
printf("\t上课时间\t缺课日期\n");
|
|
|
|
|
printf("\t%s\t%0.2f\n\n",stu[i].lesson_time,stu[i].time);
|
|
|
|
|
printf("\t迟到次数 早退次数 请假次数 旷课次数\n");
|
|
|
|
|
printf("\t%d\t\t%d\t%d\t\t%d\n",stu[i].chidao_num,stu[i].zaotui_num,stu[i].qingjia_num,stu[i].kuangke_num);
|
|
|
|
|
printf("\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
|
|
for(;k!=9;)
|
|
|
|
|
{//修改信息菜单
|
|
|
|
|
printf("\n请选择需要修改的项目:\n\n");
|
|
|
|
|
printf("\t1.学生姓名\t2.课程名称\t3.上课时间\n\n\t4.缺课日期\t5.迟到次数\t6.早退次数\n\n\t7.请假次数\t8.旷课次数\t9.退出\n");
|
|
|
|
|
scanf("%d",&k);
|
|
|
|
|
if(i<0||i>=50)
|
|
|
|
|
break;
|
|
|
|
|
printf("\n请输入修改信息:");
|
|
|
|
|
switch(k)
|
|
|
|
|
{
|
|
|
|
|
case 1:scanf("%s",stu[i].name);break;
|
|
|
|
|
case 2:scanf("%s",stu[i].lesson_name);break;
|
|
|
|
|
case 3:scanf("%s",stu[i].lesson_time);break;
|
|
|
|
|
case 4:scanf("%f",&stu[i].time);break;
|
|
|
|
|
case 5:scanf("%d",&stu[i].chidao_num);break;
|
|
|
|
|
case 6:scanf("%d",&stu[i].zaotui_num);break;
|
|
|
|
|
case 7:scanf("%d",&stu[i].qingjia_num);break;
|
|
|
|
|
case 8:scanf("%d",&stu[i].kuangke_num);break;
|
|
|
|
|
case 9:break;
|
|
|
|
|
default:printf("无该菜单选项,请重新输入\n\n");
|
|
|
|
|
}
|
|
|
|
|
printf("\n修改后的信息为:\n");
|
|
|
|
|
printf("\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
|
|
printf("%d号学生的信息为:\n\n",num);
|
|
|
|
|
printf("\t学号\t姓名\t课程名称\n");
|
|
|
|
|
printf("\t%d\t%s\t%s\n\n",stu[i].num,stu[i].name,stu[i].lesson_name);
|
|
|
|
|
printf("\t上课时间\t缺课日期\n");
|
|
|
|
|
printf("\t%s\t%0.2f\n\n",stu[i].lesson_time,stu[i].time);
|
|
|
|
|
printf("\t迟到次数 早退次数 请假次数 旷课次数\n");
|
|
|
|
|
printf("\t%d\t\t%d\t%d\t\t%d\n",stu[i].chidao_num,stu[i].zaotui_num,stu[i].qingjia_num,stu[i].kuangke_num);
|
|
|
|
|
printf("\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else//未检测到信息时记录并提示错误信息;
|
|
|
|
|
flag++;
|
|
|
|
|
if(flag==n)
|
|
|
|
|
printf("\n输入信息有误\n\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void intfac(void)
|
|
|
|
|
{//整型类数据查询
|
|
|
|
|
int num,i,flag=0;
|
|
|
|
|
scanf("%d",&num);
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{//检测是否有符合的数据
|
|
|
|
|
if(num==stu[i].num)
|
|
|
|
|
{
|
|
|
|
|
printf("\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
|
|
printf("%d号学生的信息为:\n\n",num);
|
|
|
|
|
printf("\t学号\t姓名\t课程名称\n");
|
|
|
|
|
printf("\t%d\t%s\t%s\n\n",stu[i].num,stu[i].name,stu[i].lesson_name);
|
|
|
|
|
printf("\t上课时间\t缺课日期\n");
|
|
|
|
|
printf("\t%s\t%0.2f\n\n",stu[i].lesson_time,stu[i].time);
|
|
|
|
|
printf("\t迟到次数 早退次数 请假次数 旷课次数\n");
|
|
|
|
|
printf("\t%d\t\t%d\t%d\t\t%d\n",stu[i].chidao_num,stu[i].zaotui_num,stu[i].qingjia_num,stu[i].kuangke_num);
|
|
|
|
|
printf("\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
flag++;
|
|
|
|
|
}
|
|
|
|
|
if(flag==n)
|
|
|
|
|
printf("\n输入信息有误\n\n");
|
|
|
|
|
}
|
|
|
|
|
void stringfac1(void)
|
|
|
|
|
{//字符型数据查询
|
|
|
|
|
int i,flag=0;
|
|
|
|
|
char string[40];
|
|
|
|
|
scanf("%s",string);
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{//检测是否有符合的数据
|
|
|
|
|
if(strcmp(string,stu[i].name)==0)//字符串比较
|
|
|
|
|
{
|
|
|
|
|
printf("\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
|
|
printf("%d号学生的信息为:\n\n",stu[i].num);
|
|
|
|
|
printf("\t学号\t姓名\t课程名称\n");
|
|
|
|
|
printf("\t%d\t%s\t%s\n\n",stu[i].num,stu[i].name,stu[i].lesson_name);
|
|
|
|
|
printf("\t上课时间\t缺课日期\n");
|
|
|
|
|
printf("\t%s\t%0.2f\n\n",stu[i].lesson_time,stu[i].time);
|
|
|
|
|
printf("\t迟到次数 早退次数 请假次数 旷课次数\n");
|
|
|
|
|
printf("\t%d\t\t%d\t%d\t\t%d\n",stu[i].chidao_num,stu[i].zaotui_num,stu[i].qingjia_num,stu[i].kuangke_num);
|
|
|
|
|
printf("\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
flag++;
|
|
|
|
|
}
|
|
|
|
|
if(flag==n)
|
|
|
|
|
printf("\n输入信息有误\n\n");
|
|
|
|
|
}
|
|
|
|
|
void stringfac2(void)
|
|
|
|
|
{//字符型数据查询
|
|
|
|
|
int i,flag=0;
|
|
|
|
|
char string[40];
|
|
|
|
|
scanf("%s",string);
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{//检测是否有符合的数据
|
|
|
|
|
if(strcmp(string,stu[i].lesson_name)==0)
|
|
|
|
|
{
|
|
|
|
|
printf("\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
|
|
printf("%d号学生的信息为:\n",stu[i].num);
|
|
|
|
|
printf("\t学号\t姓名\t课程名称\n");
|
|
|
|
|
printf("\t%d\t%s\t%s\n\n",stu[i].num,stu[i].name,stu[i].lesson_name);
|
|
|
|
|
printf("\t上课时间\t缺课日期\n");
|
|
|
|
|
printf("\t%s\t%0.2f\n\n",stu[i].lesson_time,stu[i].time);
|
|
|
|
|
printf("\t迟到次数 早退次数 请假次数 旷课次数\n");
|
|
|
|
|
printf("\t%d\t\t%d\t%d\t\t%d\n",stu[i].chidao_num,stu[i].zaotui_num,stu[i].qingjia_num,stu[i].kuangke_num);
|
|
|
|
|
printf("\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
flag++;
|
|
|
|
|
}
|
|
|
|
|
if(flag==n)
|
|
|
|
|
printf("\n输入信息有误\n\n");
|
|
|
|
|
}
|
|
|
|
|
void chaxun(void)
|
|
|
|
|
{//缺课信息查询
|
|
|
|
|
int k;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
printf("\n*******************************************************************\n");
|
|
|
|
|
printf("\n请选择查询项目\n\n");
|
|
|
|
|
printf("\t1.按学号查询\t2.按姓名查询\n\n\t3.按课程名查询\t4.退出查询菜单\n\n");
|
|
|
|
|
printf("\n*******************************************************************\n");
|
|
|
|
|
scanf("%d",&k);
|
|
|
|
|
switch(k)
|
|
|
|
|
{
|
|
|
|
|
case 1:printf("\n请输入学生学号:");intfac();break; //整型数据查询(学号)
|
|
|
|
|
case 2:printf("\n请输入学生姓名:");stringfac1();break; //数据类型1查询 (姓名 字符串)
|
|
|
|
|
case 3:printf("\n请输入课程名称:");stringfac2();break; //数据类型2查询 (课程名称 字符串 )
|
|
|
|
|
case 4:break;
|
|
|
|
|
default:printf("无此菜单选项,请重新输入\n\n");
|
|
|
|
|
}
|
|
|
|
|
}while(k!=4);
|
|
|
|
|
}
|
|
|
|
|
void tongji1printf(void)
|
|
|
|
|
{
|
|
|
|
|
int i,j;
|
|
|
|
|
printf("\n统计后的结果为:\n\n");
|
|
|
|
|
printf("\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
|
|
printf("\t缺课学生姓名\t旷课次数\n\n");
|
|
|
|
|
for(i=0;i<=m;i++)
|
|
|
|
|
for(j=i+1;j<=m+1;j++) //统计1 学生的旷课次数的排序 旷课多--->旷课少
|
|
|
|
|
{
|
|
|
|
|
if(kuangke[i].kuangke_num<kuangke[j].kuangke_num)
|
|
|
|
|
{
|
|
|
|
|
temp=kuangke[i];
|
|
|
|
|
kuangke[i]=kuangke[j];
|
|
|
|
|
kuangke[j]=temp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for(i=0;i<=m;i++)
|
|
|
|
|
printf("\t%s\t\t%d\n",kuangke[i].name,kuangke[i].kuangke_num);
|
|
|
|
|
printf("\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
|
|
}
|
|
|
|
|
void tongji2printf(void) //统计2
|
|
|
|
|
{
|
|
|
|
|
int i,k,j;
|
|
|
|
|
printf("\n请输入课程门数:\n");
|
|
|
|
|
scanf("%d",&k);
|
|
|
|
|
for(i=0;i<k;i++)
|
|
|
|
|
{
|
|
|
|
|
printf("\n请输入第%d门课程的名称:\n",i+1);
|
|
|
|
|
scanf("%s",kuangke2[i].name);
|
|
|
|
|
kuangke2[i].num=0;
|
|
|
|
|
printf("\n第%d门课程名称为:%s\n",i+1,kuangke2[i].name); ///旷的课的课名
|
|
|
|
|
}
|
|
|
|
|
for(j=0;j<k;j++) ///k为课程门数
|
|
|
|
|
{//统计符合检测信息的个数
|
|
|
|
|
for(i=0;i<=m;i++) // m为计数的变量 在执行这个函数前 已经令 m=k了
|
|
|
|
|
{
|
|
|
|
|
if(strcmp(kuangke2[j].name,kuangke[i].name)==0) //如果输入的课程名称是 有学生旷课的课程
|
|
|
|
|
{
|
|
|
|
|
kuangke2[j].num=kuangke2[j].num+kuangke[i].kuangke_num;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for(i=0;i<k;i++)//按从大到小排序
|
|
|
|
|
for(j=i+1;j<k+1;j++)
|
|
|
|
|
{
|
|
|
|
|
if(kuangke2[i].num<kuangke2[j].num)
|
|
|
|
|
{
|
|
|
|
|
temp2=kuangke2[i];
|
|
|
|
|
kuangke2[i]=kuangke2[j];
|
|
|
|
|
kuangke2[j]=temp2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("\n统计后的结果为:\n\n");
|
|
|
|
|
printf("\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
|
|
for(j=0;j<k;j++)
|
|
|
|
|
{
|
|
|
|
|
printf("\t课程名称\t旷课人次\n\n");
|
|
|
|
|
printf("\t%s\t\t%d\n",kuangke2[j].name ,kuangke2[j].num);
|
|
|
|
|
}
|
|
|
|
|
printf("\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
|
|
}
|
|
|
|
|
void tongjifac1(void)
|
|
|
|
|
{//信息检索
|
|
|
|
|
float time1,time2;
|
|
|
|
|
int i,flag=0,k;
|
|
|
|
|
printf("请输入起始时间和终止时间\n");
|
|
|
|
|
scanf("%f%f",&time1,&time2);
|
|
|
|
|
for(i=0,k=0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
if(stu[i].time>=time1&&stu[i].time<=time2)
|
|
|
|
|
{
|
|
|
|
|
if(stu[i].kuangke_num>0)
|
|
|
|
|
{
|
|
|
|
|
strcpy(kuangke[k].name,stu[i].name);
|
|
|
|
|
kuangke[k].kuangke_num=stu[i].kuangke_num;
|
|
|
|
|
m=k;
|
|
|
|
|
k++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
flag++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(flag==n)
|
|
|
|
|
printf("\n输入信息有误\n\n");
|
|
|
|
|
else
|
|
|
|
|
tongji1printf();
|
|
|
|
|
}
|
|
|
|
|
void tongjifac2(void)
|
|
|
|
|
{//信息检索
|
|
|
|
|
float time1,time2;
|
|
|
|
|
int i,flag=0,k;
|
|
|
|
|
printf("请输入起始时间和终止时间\n");
|
|
|
|
|
scanf("%f%f",&time1,&time2);
|
|
|
|
|
for(i=0,k=0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
if(stu[i].time>=time1&&stu[i].time<=time2)
|
|
|
|
|
{
|
|
|
|
|
if(stu[i].kuangke_num>0)
|
|
|
|
|
{
|
|
|
|
|
strcpy(kuangke[k].name,stu[i].lesson_name);
|
|
|
|
|
kuangke[k].kuangke_num=stu[i].kuangke_num;
|
|
|
|
|
m=k;
|
|
|
|
|
k++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
flag++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(flag==n)
|
|
|
|
|
printf("\n输入信息有误\n\n");
|
|
|
|
|
else
|
|
|
|
|
tongji2printf();
|
|
|
|
|
}
|
|
|
|
|
void tongji(void)
|
|
|
|
|
{//统计缺课情况
|
|
|
|
|
int k;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
printf("\n*******************************************************************\n");
|
|
|
|
|
printf("请选择统计项目\n\n");
|
|
|
|
|
printf("\n\t1.统计某段时间内,旷课学生姓名及旷课次数。\n");
|
|
|
|
|
printf("\n\t2.统计某段时间内,有学生旷课的课程及旷课人次。\n");
|
|
|
|
|
printf("\n\t3.退出统计菜单\n");
|
|
|
|
|
printf("\n*******************************************************************\n");
|
|
|
|
|
scanf("%d",&k);
|
|
|
|
|
switch(k)
|
|
|
|
|
{
|
|
|
|
|
case 1:tongjifac1();break;
|
|
|
|
|
case 2:tongjifac2();break;
|
|
|
|
|
case 3:break;
|
|
|
|
|
default:printf("\n\n无此菜单选项,请重新选择\n");
|
|
|
|
|
}
|
|
|
|
|
}while(k!=3);
|
|
|
|
|
}
|
|
|
|
|
int main(void)
|
|
|
|
|
{
|
|
|
|
|
struct Student *head;
|
|
|
|
|
int n;
|
|
|
|
|
printf("\t\t\t欢迎使用学生考勤管理系统\n\n");
|
|
|
|
|
printf("\t\t\t请统计好要输入的学生的个数\n\n");
|
|
|
|
|
printf("\t\t\t并一次性输入所有的数据\n\n");
|
|
|
|
|
printf("\t\t\t注意;本系统只能暂时保存数据\n\n");
|
|
|
|
|
printf("\t\t\t所有数据不写入文档,请做好备份\n\n");
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
printf("********************************************************************************\n\n");
|
|
|
|
|
printf("\t\t\t1.创建学生缺课记录\n\n");
|
|
|
|
|
printf("\t\t\t2.修改学生缺课记录\n\n");
|
|
|
|
|
printf("\t\t\t3.查询学生缺课记录\n\n");
|
|
|
|
|
printf("\t\t\t4.统计学生缺课记录\n\n");
|
|
|
|
|
printf("\t\t\t5.退出统一考勤管理系统\n\n");
|
|
|
|
|
printf("********************************************************************************\n");
|
|
|
|
|
scanf("%d",&n);
|
|
|
|
|
switch(n)
|
|
|
|
|
{
|
|
|
|
|
case 1:creat();break;
|
|
|
|
|
case 2:xiugai();break;
|
|
|
|
|
case 3:chaxun();break;
|
|
|
|
|
case 4:tongji();break;
|
|
|
|
|
case 5:break;
|
|
|
|
|
default:printf("无该菜单选项,请重新选择。\n\n");
|
|
|
|
|
}
|
|
|
|
|
}while(n!=5);
|
|
|
|
|
}
|
|
|
|
|
|