用c语言编译一个关于教师工作量计算管理的程序,要求:信息描述:教师编号、姓名、性别、职称、部门、课程、工作量和课酬 功能描述: 1、创建教师基本信息 2、显示所有教师信息 3、查找教师信息 4、删除教师信息 5、根据工作量计算教师的课酬
时间: 2023-11-09 19:05:56 浏览: 70
C语言课程设计-教师工作量管理系统.c
5星 · 资源好评率100%
以下是一个简单的教师工作量计算管理程序:
```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_TEACHERS 100
typedef struct {
char id[10];
char name[20];
char gender[10];
char title[20];
char department[20];
char course[20];
int workload;
int salary;
} Teacher;
Teacher teachers[MAX_TEACHERS];
int num_teachers = 0;
void add_teacher() {
Teacher new_teacher;
printf("请输入教师编号:");
scanf("%s", new_teacher.id);
printf("请输入教师姓名:");
scanf("%s", new_teacher.name);
printf("请输入教师性别:");
scanf("%s", new_teacher.gender);
printf("请输入教师职称:");
scanf("%s", new_teacher.title);
printf("请输入教师部门:");
scanf("%s", new_teacher.department);
printf("请输入教师课程:");
scanf("%s", new_teacher.course);
printf("请输入教师工作量:");
scanf("%d", &new_teacher.workload);
new_teacher.salary = new_teacher.workload * 100; // 假设每学时的课酬为100元
teachers[num_teachers++] = new_teacher;
printf("教师信息添加成功!\n");
}
void show_teachers() {
if (num_teachers == 0) {
printf("没有教师信息!\n");
return;
}
printf("教师编号\t教师姓名\t教师性别\t教师职称\t教师部门\t教师课程\t教师工作量\t教师课酬\n");
for (int i = 0; i < num_teachers; i++) {
printf("%s\t%s\t%s\t%s\t%s\t%s\t%d\t%d\n",
teachers[i].id, teachers[i].name, teachers[i].gender,
teachers[i].title, teachers[i].department, teachers[i].course,
teachers[i].workload, teachers[i].salary);
}
}
void find_teacher() {
char id[10];
printf("请输入要查找的教师编号:");
scanf("%s", id);
for (int i = 0; i < num_teachers; i++) {
if (strcmp(teachers[i].id, id) == 0) {
printf("教师编号\t教师姓名\t教师性别\t教师职称\t教师部门\t教师课程\t教师工作量\t教师课酬\n");
printf("%s\t%s\t%s\t%s\t%s\t%s\t%d\t%d\n",
teachers[i].id, teachers[i].name, teachers[i].gender,
teachers[i].title, teachers[i].department, teachers[i].course,
teachers[i].workload, teachers[i].salary);
return;
}
}
printf("没有找到该教师!\n");
}
void delete_teacher() {
char id[10];
printf("请输入要删除的教师编号:");
scanf("%s", id);
for (int i = 0; i < num_teachers; i++) {
if (strcmp(teachers[i].id, id) == 0) {
for (int j = i; j < num_teachers - 1; j++) {
teachers[j] = teachers[j+1];
}
num_teachers--;
printf("教师信息删除成功!\n");
return;
}
}
printf("没有找到该教师!\n");
}
void calculate_salary() {
int min_workload, max_workload;
printf("请输入要计算课酬的教师工作量范围:");
scanf("%d %d", &min_workload, &max_workload);
printf("教师编号\t教师姓名\t教师课酬\n");
for (int i = 0; i < num_teachers; i++) {
if (teachers[i].workload >= min_workload && teachers[i].workload <= max_workload) {
printf("%s\t%s\t%d\n", teachers[i].id, teachers[i].name, teachers[i].salary);
}
}
}
int main() {
int choice;
while (1) {
printf("\n请输入数字选择功能:\n1.创建教师基本信息\n2.显示所有教师信息\n3.查找教师信息\n4.删除教师信息\n5.根据工作量计算教师的课酬\n0.退出程序\n");
scanf("%d", &choice);
switch(choice) {
case 0:
printf("程序已退出!\n");
exit(0);
case 1:
add_teacher();
break;
case 2:
show_teachers();
break;
case 3:
find_teacher();
break;
case 4:
delete_teacher();
break;
case 5:
calculate_salary();
break;
default:
printf("输入有误,请重新输入!\n");
break;
}
}
return 0;
}
```
该程序使用了结构体存储教师信息,通过函数实现不同的功能。其中计算课酬的做法是假设每学时的课酬为100元,根据工作量计算出总课酬。该程序还使用了循环和选择结构,可以不断地进行操作,直到用户选择退出程序。
阅读全文