📄 classmanage.c
字号:
#include <stdio.h> /*standard input and output标准输入输出函数*/
#include<string.h> /*字符串函数*/
#include <conio.h> /**getch()的引入*/
#define null 0;
/************************所有的结构体**********************/
typedef struct /*3时间结构体*/
{ int weekday; /*星期几*/
int jieci; /*节次*/
}Cot;
typedef struct /*1学生个人信息结构体*/
{char sname[20];
char snum[5];
char ssex[5];
char sclass[10];
float grade;
}Student;
typedef struct /*2课程结构体*/
{char cname[20]; /*课程名字*/
char cnum[6]; /*课程号*/
Cot ctime; /*上课时间*/
char cclassroom[10]; /*上课教室*/
}Course;
typedef struct /*4学校课程结构体*/
{ Course cou1;
Student stu1[100];
int stnum;
}Scc;
typedef struct /*5学生课程结构体*/
{ Student stu2;
int conum; /*课程数*/
Course cou2[30]; /*最大30门课程*/
}Sco;
/************************函数声明****************************/
void setst(Student *p_student); /*1学生个人信息的设置*/
void showstudent(Student *p_student); /*输出学生个人信息*/
void setgrade(Student *p_student); /*设置学生的成绩*/
void setco(Course *p_course); /*2课程信息的设置*/
void showcourse(Course *p_course); /*输出课程信息*/
void changeco(Course *p_course); /*上课时间地点的更改*/
void setcot(Cot *p_time); /*3时间的设置*/
void showcot(Cot *p_time); /*时间的输出*/
void show_scc_student(Scc *p_scc_student); /*4课程学生的名单*/
void show_scc_grade(Scc *p_scc_student); /*课程学生的成绩*/
Scc set_scc_course(Scc *p_scc_student); /*设置学校课程*/
void show_sco_time_classroom(Scc *p_scc_student); /*输出上课时间地点*/
void add_sco_course(Sco *p_sco_student); /*5从学生课表中增加课程*/
void delete_sco_course(Sco *p_sco_student); /*从学生课表中删除课程*/
Sco set_sco_course(Sco *p_sco_student); /*设置学生的课程表*/
int showmeun(); /******系统主菜单******/
/************************链表的说明****************************/
/*1学校课程*/
typedef struct link_node_scc
{ Scc info;
struct link_node_scc *next;
}nodescc;
/*2学生课程*/
typedef struct link_node_sco
{ Sco info;
struct link_node_sco *next;
}nodesco;
nodescc *init_hlink_list_scc() /*链表初始化*/
{ nodescc *head;
head=(nodescc *)malloc(sizeof(nodescc));
head->next=null;
return head;
}
nodesco *init_hlink_list_sco() /*链表初始化*/
{ nodesco *head;
head=(nodesco *)malloc(sizeof(nodesco));
head->next=null;
return head;
}
/*学校链表的操作*/
nodescc *luru_scc(nodescc *head); /*1录入学校课程***************/
nodescc *change_scc(nodescc *head); /*2修改学校课程的上课时间地点*/
void print_scc(nodescc *head); /*3查询学校上课时间和地点*****/
void look_scc(nodescc *head); /*4查找学校某门课程的学生名单*/
void output_scc_grade(nodescc *head); /*5输出学校某门课程的学生成绩*/
nodescc *dele_scc(nodescc *head); /*6删除学校的某门课程*********/
nodescc *add_scc(nodescc *head); /*7增加学校的课程*************/
/*学生课程表的操作*/
nodesco *luru_sco(nodesco *head); /*1录入学生的课程表*/
nodesco *add_sco(nodesco *head); /*2在学生课程表内增加一门课程*/
nodesco *dele_sco(nodesco *head); /*3在学生课程表内删除一门课程*/
void cha_sco(nodesco *head); /*4查询学生的课程表*/
void look_sco(nodesco *head); /*5浏览学生的课程表*/
/**********************系统函数********************/
nodescc *sccsub(nodescc *head); /********学生课程表管理子菜单*****/
nodesco *scosub(nodesco *head); /*****学校课程管理子系统****/
nodescc *find_char_scc(nodescc *head,char a[20]); /*学校课程字符查找*/
nodesco *find_char_sco(nodesco *head,char a[20]); /*学生的课程表的字符查找*/
/************************主函数****************************/
main()
{int in;
nodescc *zscc;
nodesco *zsco;
zscc=init_hlink_list_scc();
zsco=init_hlink_list_sco();
do
{
system("cls");
in=showmeun(); /*系统主菜单显示*/
switch(in)
{
case 1 : zscc=sccsub(zscc);
break;
case 2 : zsco=scosub(zsco);
break;
case 3 : break;
default: printf("cannot fin it and Press any key to continue...\n\n");
getch(); /*等待输入任一键,从屏幕读一个字符不显示在屏幕上*/
clrscr();
break;
}
}while(in!=3);
system("cls");
printf("Bay_Bay");
}
/************************函数体*******************************/
/*****************************1学生*************/
void setst(Student *p_student) /*1学生个人信息的设置*/
{
printf("\nInput student name:\n ");
scanf("%s",p_student->sname);
printf("\nInput student Class No.:\n "); /*输入学生的学号*/
scanf("%s",p_student->snum);
printf("\nInput student sex:\n ");
scanf("%s",p_student->ssex);
printf("\nInput class where stduent:\n "); /*学生所在班级*/
scanf("%s",p_student->sclass);
}
void showstudent(Student *p_student) /*输出学生个人信息*/
{printf("\nThe Student name's is:%s\n ",p_student->sname);
printf("\nThe Student number's is:%s\n ",p_student->snum);
printf("\nThe Student's sex is:%s\n ",p_student->ssex);
printf("\nThe Student's class is:%s\n ",p_student->sclass);
printf("\nThe Student's grade is:%s\n",p_student->grade);
}
void setgrade(Student *p_student) /*设置学生的成绩*/
{ float i;
printf("Please input grade of the student:\n");
scanf("%f",&i);
p_student->grade=i;
}
/**********************2课程*************************/
void setco(Course *p_course) /*2,1课程信息的设置*/
{ printf("\nInput course name:\n ");
scanf("%s",p_course->cname);
printf("\nInput course No.:\n ");
scanf("%s",p_course->cnum);
printf("\nInput course time:\n ");
setcot(&p_course->ctime);
printf("\nInput course classroom:\n ");
scanf("%s",p_course->cclassroom);
}
void showcourse(Course *p_course) /*2输出课程信息*/
{printf("\nThe course's name is:%s\n ",p_course->cname);
printf("\nThe course's number is:%s\n ",p_course->cnum);
printf("\nThe course's time is:%s\n ");
showcot(&p_course->ctime);
printf("\nThe course's place is:%s\n ",p_course->cclassroom);
}
void changeco(Course *p_course) /*3上课时间地点的更改*/
{char ch;
printf("******\n");
printf("--Please input new time of class:\n\n");
setcot(&p_course->ctime);
printf("\n");
printf("Do you want change the classroom of class?(y/n)\n");
fflush(stdin);
scanf("%c",&ch);
if(ch=='y'||ch=='Y')
{
printf("Please input new classroom:\n");
scanf("%s",p_course->cclassroom);
printf("\n");
}
clrscr();
}
/****************************3时间**********************/
void setcot(Cot *p_time) /*3,1时间的设置*/
{
printf("Input a int weekday(1~7):\n ");
scanf("%d",&p_time->weekday);
printf("Input a int jieci(1~5):\n ");
scanf("%d",&p_time->jieci);
}
void showcot(Cot *p_time) /*2时间的输出*/
{ printf("------The weekday of class is: %d\n",p_time->weekday);
printf("------The jieci of class is: %d \n",p_time->jieci);
}
/*************************************4学校课程*******************************************/
void show_scc_student(Scc *p_scc_student) /*4,(4)课程学生的名单*/
{ int i;
printf("The student name list is: \n\n");
for(i=0;i<p_scc_student->stnum;i++)
printf("The student %d name is %s: \n",(i+1),p_scc_student->stu1[i].sname);
}
void show_scc_grade(Scc *p_scc_student) /*课程学生的成绩*/
{int i;
printf("The student grade list is: \n\n");
for(i=0;i<p_scc_student->stnum;i++)
{
printf("The student %d is : %f\n\n",i+1,p_scc_student->stu1[i].grade);
}
}
Scc set_scc_course(Scc *p_scc_student) /*4设置学校课程*/
{int count;
printf("Please input information of class:\n");
setco(&p_scc_student->cou1);
printf("Please input total number of student: \n");
scanf("%d",&p_scc_student->stnum);
for(count=0;count<p_scc_student->stnum;count++)
{printf("Please input student %d:" ,(count+1));
setst(&p_scc_student->stu1[count]);
setgrade(&p_scc_student->stu1[count]);
}
system("cls");
return *p_scc_student;
}
void show_sco_time_classroom(Scc *p_scc_student) /*输出上课时间地点*/
{ printf("\n\n");
printf("The time of the course is :\n");
showcot(&p_scc_student->cou1.ctime);
printf("------The classroom of the course: %s \n",p_scc_student->cou1.cclassroom);
}
/****************************************5学生课程**********************************/
Sco set_sco_course(Sco *p_sco_student) /*5设置学生的课程表*/
{ int i;
int j;
printf("Please input the information of the student:\n");
setst(&p_sco_student->stu2);
printf("Please input the total of the student course:\n"); /*学生课程总数*/
scanf("%d",&j);
p_sco_student->conum=j;
for(i=0;i<j;i++)
{
printf("Please input course %d information:\n",i+1);
setco(&p_sco_student->cou2[i]); }
return *p_sco_student;
}
void add_sco_course(Sco *p_scc_student) /*5从学生课表中增加课程*/
{ printf("Please input new a course:\n");
setco(&p_scc_student->cou2[p_scc_student->conum]);
p_scc_student->conum++;
}
void delete_sco_course(Sco *p_scc_student) /*从学生课表中删除课程*/
{int i=0,j;
char a[20];
printf("Please input course deleting name :\n");
while(strcmp(a,p_scc_student->cou2[i].cname))
{i++;}
for(j=0;j<p_scc_student->conum;j++);
{ p_scc_student->cou2[j]=p_scc_student->cou2[j+1];
}
p_scc_student->conum--;
}
/*********************************学校课程***************************************/
nodescc *luru_scc(nodescc *head) /*1录入学校课程*/
{char ch;
nodescc *q,*k;
Scc m;
int i=1;
k=head;
do{
q=(nodescc *)malloc(sizeof(nodescc));
printf("\n\n\n");
printf("Please input course %d\n",i);
printf("\n\n\n");
m=set_scc_course(&m);
q->info=m;
k->next=q;
k=k->next;
q->next=null;
system("cls");
printf("\n\n\n\n\n\n");
printf("Do you want to continue to input under course information?(y/n)\n\n");
do{fflush(stdin);
scanf("%c",&ch);
}while((ch!='N'&&ch!='n')&&(ch!='Y'&&ch!='y'));
i++;
}while(ch=='Y'||ch=='y');
system("cls");
return head;}
nodescc *change_scc(nodescc *head) /*2修改学校课程的上课时间地点*/
{ char a[20],ch;
nodescc *m;
m=head->next;
do{
if(!m) printf("No informatiom!\n");
else{ printf("Please input the course name that will change:\n");
scanf("%s",&a);
fflush(stdin);
m=find_char_scc(m,a);
if(m)
{printf("Please input new course time and classroom:\n\n");
changeco(&m->info.cou1);
}
return head;}
printf("Do you want to continue to chang course time and classroom?(y/n)\n\n");
do{
fflush(stdin);
scanf("%c",&ch);}while((ch!='N'&&ch!='n')&&(ch!='Y'&&ch!='y'));
}while(ch=='y'||ch=='Y');
}
void print_scc(nodescc *head) /*3查询学校上课时间和地点*/
{ nodescc *p;
nodescc *m;
char ch[20],a;
p=head->next;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -