#include
#include
#include
struct people{
int id;
char name[20];
char sex[5];
char title[20];//职称
char post[20];//职务
char course[20];
int score;//评分
}teacher[100];
void insert(){
int _id;
printf("Please enter teacher information\n");
printf("id = ");
scanf_s("%d",&_id);
if(_id > 0 &&_id < 100){
if(teacher[_id].id == _id){
printf("Teacher exist\n");
return;
}
else{
char _name[20];
char _sex[5];
char _title[20];
char _post[20];
char _course[20];
printf("name = ");
scanf_s("%s",&_name);
printf("sex = ");
scanf_s("%s",&_sex);
printf("title = ");
scanf_s("%s",&_title);
printf("post = ");
scanf_s("%s",&_post);
printf("course = ");
scanf_s("%s",&_course);
teacher[_id].id = _id;
strcpy_s(teacher[_id].name,_name);
strcpy_s(teacher[_id].sex,_sex);
strcpy_s(teacher[_id].title,_title);
strcpy_s(teacher[_id].post,_post);
strcpy_s(teacher[_id].course,_course);
printf("Insert successfully\n");
}
}
else{
printf("Insert failed\n");
}
return;
}
void revise(){
int _id;
printf("Please enter teacher id\n");
scanf_s("%d",&_id);
if(teacher[_id].id == _id){//教师信息存在
char _name[20];
char _sex[5];
char _title[20];
char _post[20];
char _course[20];
printf("Teacher information is as follows\n");
printf("id = %d ",teacher[_id].id);
printf("name = %s ",teacher[_id].name);
printf("sex = %s ",teacher[_id].sex);
printf("title = %s ",teacher[_id].title);
printf("post = %s ",teacher[_id].post);
printf("course = %s\n",teacher[_id].course);
printf("Please revise teacher information\n");
printf("name = ");
scanf_s("%s",_name);
printf("sex = ");
scanf_s("%s",_sex);
printf("title = ");
scanf_s("%s",_title);
printf("post = ");
scanf_s("%s",_post);
printf("course = ");
scanf_s("%s",_course);
strcpy_s(teacher[_id].name,_name);
strcpy_s(teacher[_id].sex,_sex);
strcpy_s(teacher[_id].title,_title);
strcpy_s(teacher[_id].post,_post);
strcpy_s(teacher[_id].course,_course);
printf("Revise successfully\n");
}
else{
printf("Teacher does not exist\n");
}
return;
}
void del(){
int _id;
printf("Please enter teacher id\n");
scanf_s("%d",&_id);
if(teacher[_id].id == _id){//教师信息存在
memset(&teacher[_id],0,sizeof(teacher[_id]));
printf("Delete successfully\n");
}
else{
printf("Teacher does not exist\n");
}
return;
}
void browse(){
int _id;
printf("Please enter teacher id\n");
scanf_s("%d",&_id);
if(teacher[_id].id == _id){//教师信息存在
printf("Teacher information is as follows\n");
printf("id = %d ",teacher[_id].id);
printf("name = %s ",teacher[_id].name);
printf("sex = %s ",teacher[_id].sex);
printf("title = %s ",teacher[_id].title);
printf("post = %s ",teacher[_id].post);
printf("course = %s\n",teacher[_id].course);
printf("score = %d\n",teacher[_id].score);
}
else{
printf("Teacher does not exist\n");
}
return;
}
void evaluate(){
int _id;
int sum = 0;
printf("Please enter teacher id\n");
scanf_s("%d",&_id);
if(teacher[_id].id == _id){//教师信息存在
if(teacher[_id].score == 0){
int _score;
printf("Each item full marks is 10\n");
printf("prepare lessons = ");//备课
scanf_s("%d",&_score);
sum += _score;
printf("teaching = ");//授课
scanf_s("%d",&_score);
sum += _score;
printf("style = ");//风格
scanf_s("%d",&_score);
sum += _score;
printf("homework = ");//作业
scanf_s("%d",&_score);
sum += _score;
printf("practice = ");//练习
scanf_s("%d",&_score);
sum += _score;
printf("discipline = ");//纪律
scanf_s("%d",&_score);
sum += _score;
printf("vivid = ");//生动
scanf_s("%d",&_score);
sum += _score;
printf("answering question = ");//答疑
scanf_s("%d",&_score);
sum += _score;
printf("content = ");//内容
scanf_s("%d",&_score);
sum += _score;
printf("punctual = ");//准时
scanf_s("%d",&_score);
sum += _score;
teacher[_id].score = sum;
}
else{
printf("Teacher has been evaluated\n");
return;
}
printf("Teacher evaluation score is %d\n",sum);
}
else{
printf("Teacher does not exist\n");
}
return;
}
void Menu(){
int a;
printf("**********Menu**********\n");
printf("1.insert\n");//插入
printf("2.revise\n");//修改
printf("3.delete\n");//删除
printf("4.browse\n");//浏览
printf("5.evaluate\n");//评价
printf("6.quit\n");//退出
printf("Please input operation\n");
scanf_s("%d",&a);
switch(a){
case 1: insert();break;
case 2: revise();break;
case 3: del();break;
case 4: browse();break;
case 5: evaluate();break;
case 6: exit(0);break;
default: break;
}
return;
}
int main(void){
while(1){
Menu();
}
return 0;
}