【文件属性】:
文件名称:教 师 工 作 量 管 理 系 统
文件大小:7KB
文件格式:CPP
更新时间:2013-10-20 17:16:28
课程设计
#include
#include
#include
#include
#include
#define MAX_NAME 20
#define NULL 0
struct course
{
char course_name[MAX_NAME];
int class_num;
int ch_per;
int ex_per;
struct course *next;
};
struct teacher
{
char teacher_num[MAX_NAME];
char teacher_name[MAX_NAME];
struct teacher *next;
struct course *chead;
struct course *ctail;
};
struct teacher *thead,*ttail,*found;
//***********************************************************************
//主菜单
void menu()
{
system("cls");
printf("*************************************\n");
printf("* 1.输入教师信息 *\n");
printf("* 2.插入授课信息 *\n");
printf("* 3.工作量计算与显示 *\n");
printf("* 4.退出 *\n");
printf("*************************************\n");
printf("请输入要操作的序号:");
}
int isExist(char number[]) //判断输入的教师号是否已经存在
{
struct teacher *p;
p=thead;
while(p!=NULL && (strcmp(p->teacher_num,number)!=0)) p=p->next;
found=p;
if(p==NULL)
return 0;
else
return 1;
}
//************************************************************************
//增加教师教学信息模块
void addIn()
{
struct teacher *p;
struct course *pcourse;
char teacher_num[MAX_NAME];
char teacher_name[MAX_NAME];
char course_name[MAX_NAME];
int class_num;
int ch_per;
int ex_per;
while(1)
{
system("cls");
printf("****************************************************\n");
printf("* 输入教师的信息,以输入教师号为#结束输入 *\n");
printf("****************************************************\n");
printf("输入教师号:");
fflush(stdin);
scanf("%s",teacher_num);
if(isExist(teacher_num))
{
printf("!!!该教师号已经存在,请重新输入。\n按任意键重新输入...\n");
getch();
}
else
{
if(strcmp(teacher_num,"#")==0)
{
printf("**************************************************\n");
printf("输入结束。按任意键返回主菜单...\n");
getch();
return;
}
printf("输入教师姓名:");fflush(stdin);scanf("%s",teacher_name);
printf("****************************************************\n");
printf("* 输入教师授课信息 *\n");
printf("****************************************************\n");
printf("输入课程名称:");fflush(stdin);scanf("%s",course_name);
printf("输入班级数目:");fflush(stdin);scanf("%d",&class_num);
printf("输入理论课时:");fflush(stdin);scanf("%d",&ch_per);
printf("输入实验课时:");fflush(stdin);scanf("%d",&ex_per);
pcourse=(struct course *)malloc(sizeof(struct course));
strcpy(pcourse->course_name,course_name);
pcourse->class_num=class_num;
pcourse->ch_per=ch_per;
pcourse->ex_per=ex_per;
pcourse->next=NULL;
p=(struct teacher *)malloc(sizeof(struct teacher));
strcpy(p->teacher_num,teacher_num);
strcpy(p->teacher_name,teacher_name);
p->chead=pcourse;
p->ctail=pcourse;
if(thead==NULL)
{
thead=p;
ttail=p;
}
else
{
ttail->next=p;
ttail=p;
}
ttail->next=NULL;
}
}
}
//************************************************************************
//插入教师授课信息模块
void addCourseInfo()
{
struct course *pcourse;
char teacher_num[MAX_NAME];
char course_name[MAX_NAME];
int class_num;
int ch_per;
int ex_per;
system("cls");
if(thead==NULL)
{
printf("****************************************************\n");
printf("* 当前没有可用的教师信息,按任意键返回主菜单... *\n");
printf("****************************************************\n");
getch();
return;
}
while(1)
{
system("cls");
printf("输入教师号:");fflush(stdin);scanf("%s",teacher_num);
if(isExist(teacher_num))
break;
else
{
printf("!!!该教师号不存在,请重新输入.\n按任意键重新输入...\n");
getch();
}
}
printf("****************************************************\n");
printf("* 输入教师授课信息 *\n");
printf("****************************************************\n");
printf("输入课程名称:");fflush(stdin);scanf("%s",course_name);
printf("输入班级数目:");fflush(stdin);scanf("%d",&class_num);
printf("输入理论课时:");fflush(stdin);scanf("%d",&ch_per);
printf("输入实验课时:");fflush(stdin);scanf("%d",&ex_per);
pcourse=(struct course *)malloc(sizeof(struct course));
strcpy(pcourse->course_name,course_name);
pcourse->class_num=class_num;
pcourse->ch_per=ch_per;
pcourse->ex_per=ex_per;
pcourse->next=NULL;
found->ctail->next=pcourse;
found->ctail=pcourse;
}
//************************************************************************
//计算并显示
void calcu()
{
struct teacher *p;
struct course *pcourse;
float single_per=0.0;
float total_per=0.0;
system("cls");
if(thead==NULL)
{
printf("****************************************************\n");
printf("* 当前没有可用的教师信息,按任意键返回主菜单... *\n");
printf("****************************************************\n");
getch();
return;
}
p=thead;
while(p!=NULL)
{
total_per=0.0;
printf("----------------------------------------------------------------------\n");
printf("教师号:%s\n",p->teacher_num);
printf("教师姓名:%s\n",p->teacher_name);
printf("----------------------------------------------------------------------\n");
printf("课程名称 班级数目 理论课时 实验课时 单教学任务总课时\n");
printf("----------------------------------------------------------------------\n");
pcourse=p->chead;
while(pcourse!=NULL)
{
single_per=0.0;
if(pcourse->class_num==1) single_per=pcourse->ch_per+pcourse->ex_per;
if(pcourse->class_num==2) single_per=1.5*(pcourse->ch_per+pcourse->ex_per);
if(pcourse->class_num==3) single_per=2.0*(pcourse->ch_per+pcourse->ex_per);
if(pcourse->class_num>=4) single_per=2.5*(pcourse->ch_per+pcourse->ex_per);
printf("%-10s%-10d%-10d%-10d%-7.3f\n",pcourse->course_name,pcourse->class_num,pcourse->ch_per,pcourse->ex_per,single_per);
total_per+=single_per;
pcourse=pcourse->next;
}
printf("----------------------------------------------------------------------\n");
printf("一个学期总的教学工作量:%7.3f\n",total_per);
printf("----------------------------------------------------------------------\n\n\n\n");
p=p->next;
}
printf("\t****************************************************\n");
printf("\t* 已经显示完毕,按任意键返回主菜单... *\n");
printf("\t****************************************************\n");
getch();
}
//************************************************************************
//主函数
void main()
{
int order;
while(1)
{
menu();
fflush(stdin);
scanf("%d",&order);
switch (order)
{
case 1:addIn();break;
case 2:addCourseInfo();break;
case 3:calcu();break;
case 4:exit(0);break;
default:
printf("输入的序号有误,请检查后重新输入...\n");
getch();
break;
}
}
}