link 28 加了登分与查分的
2005-08-05 23:42
183 查看
#include <stdio.h>
#include <stdlib.h>
/*********************************/
#define LENGTH_STU_COURSE_NUMBER 16
#define LENGTH_CLASS_MAJOR 26
#define LENGTH_CLASS_NUMBER 16
#define LENGTH_CLASS_MASTER_NAM 16
#define LENGTH_CLASS_MASTER_NUM 16
#define LENGTH_CLASS_NUMBER 16
#define LENGTH_CLASS_NUM 7
#define LENGTH_CLASS_YUANXI 16
#define LENGTH_STU_NAM 16
#define LENGTH_STU_NUMBER 16
#define LENGTH_STU_SEX 11
#define LENGTH_STU_TEL 16
#define LENGTH_STU_AGE 3
#define LENGTH_STU_CLASSNUMBER 16
#define LENGTH_STU_MAJOR 26
#define LENGTH_STU_CLASS_NUM 5
#define LENGTH_STU_COURSE 15
#define LENGTH_STU_ID 20
#define LENGTH_DORM_CAMPUS_NAM 16
#define LENGTH_DORM_NUM 5
#define LENGTH_DORM_MODE 21
#define LENGTH_DORM_NET 4
#define LENGTH_DORM_TEL 16
#define LENGTH_DORM_NUMBER 16
#define LENGTH_COURSE_NUMBER 16
#define LENGTH_COURSE_NAM 16
#define LENGTH_COURSE_DATE 12
#define LENGTH_TEACHER_NAM 16
#define LENGTH_TEACHER_NUM 16
#define LENGTH_TEACHER_SEX 11
#define LENGTH_TEACHER_BIRTH 11
#define LENGTH_TEACHER_MODE 21
#define LENGTH_TEACHER_TEL 16
#define LENGTH_TEACHER_NUMBER 16
#define LENGTH_TEACHER_ID 20
#define LENGTH_YUANXI_NUMBER 16
#define LENGTH_YUANXI_NAME 26
#define LENGTH_YUANXI_HEADMASTER 26
#define LENGTH_MAJOR_NAM 26
#define LENGTH_MAJOR_NUMBER 16
#define LENGTH_MAJOR_YUANXI_NAM 26
#define PASSWORD 16
/*********************************/
struct student * head_stu;
struct student *p_stu;
struct dorm *head_dorm;
struct dorm *p_dorm;
struct teacher * head_tea;
struct teacher *p_tea;
struct course *head_cou;
struct course *p_cou;
struct yuanxi *head_yua;
struct yuanxi *p_yua;
struct class *head_cla;
struct class *p_cla;
struct major *head_maj;
struct major *p_maj;
struct stu_course *head_stu_cou;
struct stu_course *p_stu_cou;
/*********************************/
struct yuanxi
{
char yuanxi_number[LENGTH_YUANXI_NUMBER];
char yuanxi_nam[LENGTH_YUANXI_NAME];
char yuanxi_headmaster[LENGTH_YUANXI_HEADMASTER];
struct teacher * yuanxi_pt; /*这是用来记录院系负责人的指针*/
struct yuanxi * yuanxi_py; /*指向下个院系*/
struct class * yuanxi_pc; /*指向开始的班级*/
struct major *yuanxi_pm; /*the pionter used to create a chain of major in a struct yuanxi*/
};
struct class
{
char class_yuanxi[LENGTH_CLASS_YUANXI];
char class_major[LENGTH_CLASS_MAJOR];
char class_num[LENGTH_CLASS_NUM]; /*the number used in major*/ /*这几个可以合起来得出班级的唯一标识*/
char class_master_nam[LENGTH_CLASS_MASTER_NAM];
char class_master_num[LENGTH_CLASS_MASTER_NUM];
char class_number[LENGTH_CLASS_NUMBER]; /*the only one sign used in the files*/
struct student *class_ps; /*the pointer of student used in the class*/
struct class *pc;
struct major * class_pm;
struct class *major_pc; /*the pionter will be used in the struct major*/
};
struct teacher
{
char teacher_nam [LENGTH_TEACHER_NAM];
char teacher_sex[LENGTH_TEACHER_SEX];
char teacher_birth[LENGTH_TEACHER_BIRTH];
char teacher_mode[LENGTH_TEACHER_MODE];
char teacher_tel[LENGTH_TEACHER_TEL];
char teacher_number[LENGTH_TEACHER_NUMBER]; /*the only sign of the teacher*/
char teacher_course_number[LENGTH_COURSE_NUMBER];
char teacher_id[LENGTH_TEACHER_ID];
char teacher_password[PASSWORD];
int teacher_salary;
struct course * tea_pc; /*the pionter to the teacher of the course*/
struct teacher *tea_pt; /*the pionter used in the chain of the teacher*/
};
struct dorm
{
char dorm_campus_nam[LENGTH_DORM_CAMPUS_NAM];
int dorm_build_num;
char dorm_num[LENGTH_DORM_NUM];
char dorm_mode[LENGTH_DORM_MODE];
char dorm_internet[LENGTH_DORM_NET];
char dorm_tel[LENGTH_DORM_TEL];
char dorm_number[LENGTH_DORM_NUMBER]; /*the only sign of the dorm*/
int dorm_stu_num;
int dorm_good;
struct dorm *pd; /*the pionter to a dorm used in the chain of the dorm*/
struct student * ps; /*the pionter to a student in the chain of the student */
};
struct course
{
char course_number[LENGTH_COURSE_NUMBER]; /*the only sign of the course*/
char course_nam[LENGTH_COURSE_NAM];
char course_date[LENGTH_COURSE_DATE];
struct teacher * course_pt; /*the pionter to a teacher in the chain of the teacher*/
struct course *course_pc;
};
struct stu_course
{
char stu_course_number[LENGTH_COURSE_NUMBER];
char stu_course_stu_number[LENGTH_STU_NUMBER];
struct course *cour; /*the pionter to a course in the chain of the struct of student*/
struct student *pss; /*the pionter to a student who learn the course*/
struct stu_course * psc; /*the pointer to a stu_course in the chain of the stu_course*/
struct stu_course * stu_course_psc; /*the pionter to the chain of the stu_course*/
int mark;
};
struct student
{
char stu_number[LENGTH_STU_NUMBER];
char stu_nam[LENGTH_STU_NAM];
char stu_sex[LENGTH_STU_SEX];
char stu_age[LENGTH_STU_AGE];
char stu_tel[LENGTH_STU_TEL];
char stu_major[LENGTH_STU_MAJOR];
char stu_class_num[LENGTH_STU_CLASS_NUM];
char classnumber[LENGTH_STU_CLASSNUMBER]; /*the only one sign of the class used in files*/
char stu_dorm_number[LENGTH_DORM_NUMBER]; /*the number of dorm will be used in the recreate the chain, and will
be made by the other */
char stu_id[LENGTH_STU_ID];
char stu_password[PASSWORD];
struct class *stu_class_pc; /*the pointer to the class*/
struct stu_course *stu_pc; /*the chain of the courses student chosed*/
struct dorm * stu_dorm; /*the dorm the student lived*/
struct student * stu_dorm_ps; /*the pointer of the student used in the struct of the dorm*/
struct student * stu_ps; /*the pointer of the student used in the chain of the student*/
struct student * stu_class_ps; /*the pointer used in class chain*/
};
struct major
{
char major_nam[LENGTH_MAJOR_NAM];
char major_yuanxi_nam[LENGTH_MAJOR_NAM];
char major_num[LENGTH_MAJOR_NUMBER];
struct major * major_yuanxi_pm; /* !!!!!!!!!!! ----repeat-----!!!!!!!!! */
struct major * pm;
struct class * major_pc;
};
/**********************************/
void create_stu (struct student **,struct student *);
void show_stu (struct student **);
void create_dorm (struct dorm **,struct dorm *);
void show_dorm (struct dorm **);
void create_tea(struct teacher **,struct teacher *);
void show_tea(struct teacher **);
void create_cou (struct course **,struct course *);
void show_cou (struct course **);
void create_yua (struct yuanxi **,struct yuanxi *);
void show_yua (struct yuanxi **);
void create_cla (struct class **,struct class *);
void create_maj(struct major**,struct major *);
void show_maj (struct major **);
void create_stu_cou(struct stu_course **,struct stu_course *);
void main_menu (void);
void add_menu (void);
void show_menu (void);
void choose_menu (void);
void create_stu_class (struct student *,struct class *); /*put the student in the chain in struct class*/
void check_stu_class (struct student *,struct class **); /*when you input a student,put it to the chain in struct class which have been created*/
void create_class_major(struct class*,struct major *);
void check_class_major(struct class *,struct major **);
void create_major_yuanxi(struct major *,struct yuanxi *);
void check_major_yuanxi(struct major *,struct yuanxi **);
int choose_course (struct stu_course *);
int test_course (void);
int choose_course_yuanxi (struct stu_course *);
int choose_course_major (struct stu_course *p_stu_cou);
int write_mark (struct stu_course *);
int check_mark (struct student *);
/**********************************/
void main (void)
{
char cc;
int tag=1;
while(tag)
{
main_menu();
}
getchar();
}
/********************************** function used in all *********************/
void main_menu (void)
{
char main_c;
puts("+++++++++++++++MENU++++++++++++");
puts(" 1.Add.");
puts(" 2.Show.");
puts(" 3.Xuanke.");
puts(" 4.Test.");
puts(" 5.Exit.");
main_c=getch();
switch(main_c)
{
case '1':
add_menu();
break;
case '2':
show_menu();
break;
case '3':
choose_menu();
break;
case '4':
test_course();
break;
case '5':
exit(0);
default :
break;
}
}
void add_menu (void)
{
char add_c;
puts("+++++++++++++++MENU++++++++++++");
puts(" 1.Add Student.");
puts(" 2.Add Dorm.");
puts(" 3.Add Teacher.");
puts(" 4.Add Course.");
puts(" 5.Add Yuanxi.");
puts(" 6.Add Major");
puts(" 7.Add Cla");
add_c=getch();
switch(add_c)
{
case '1':
create_stu(&head_stu,p_stu);
break;
case '2':
create_dorm(&head_dorm,p_dorm);
break;
case '3':
create_tea(&head_tea,p_tea);
break;
case '4':
create_cou(&head_cou,p_cou);
break;
case '5':
create_yua(&head_yua,p_yua);
break;
case '6':
create_maj(&head_maj,p_maj); puts("Ok!");
break;
case '7':
create_cla(&head_cla,p_cla);
break;
}
}
void show_menu (void)
{
char show_c;
puts("+++++++++++++++MENU++++++++++++");
puts(" 1.Show Student.");
puts(" 2.Show Dorm.");
puts(" 3.Show Teacher.");
puts(" 4.Show Course.");
puts(" 5.Show Yuanxi.");
puts(" 6.Show Major.");
show_c=getch();
switch(show_c)
{
case '1':
show_stu(&head_stu);
break;
case '2':
show_dorm(&head_dorm);
break;
case '3':
show_tea(&head_tea);
break;
case '4':
show_cou(&head_cou);
break;
case '5':
show_yua(&head_yua);
break;
case '6':
show_maj(&head_maj);
break;
}
}
void choose_menu (void)
{
char c_choose;
puts("--------choose the course---------");
puts(" 1.student.");
puts(" 2.yuanxi.");
puts(" 3.major.");
puts(" 4.write mark.");
puts(" 5.check mark.");
c_choose=getch();
switch(c_choose)
{
case '1':
choose_course(p_stu_cou);
break;
case '2':
choose_course_yuanxi(p_stu_cou);
break;
case '3':
choose_course_major(p_stu_cou);
break;
case '4':
write_mark(head_stu_cou);
break;
case '5':
check_mark(head_stu);
break;
default:
break;
}
}
/*************************** the function of the student*******************************/
void create_stu (struct student **head_stu,struct student *p_stu) /*the function to add a node of the link of the student*/
{
p_stu=(struct student *)malloc (sizeof(struct student));
puts("input the number of the student:");
gets(p_stu->stu_number);
puts("input the name of the student:");
gets(p_stu->stu_nam);
puts("input the sex of the student:");
gets(p_stu->stu_sex);
puts("input the age of the student:");
gets(p_stu->stu_age);
puts("input the ID of the student:");
gets(p_stu->stu_id);
puts("input the tel of the student:");
gets(p_stu->stu_tel);
puts("input the major of the student:");
gets(p_stu->stu_major);
puts("input the class number of the student:");
gets(p_stu->stu_class_num);
puts("input the onlynumber of the class:");
gets(p_stu->classnumber);
p_stu->stu_class_pc=NULL; /*the pointer to the class*/
p_stu->stu_pc=NULL; /*the chain of the courses student chosed*/
p_stu->stu_dorm=NULL; /*the dorm the student lived*/
p_stu->stu_dorm_ps=NULL; /*the pointer of the student used in the struct of the dorm*/
p_stu->stu_ps=NULL; /*the pointer of the student used in the chain of the student*/
p_stu->stu_class_ps=NULL;
if(*head_stu==NULL)
*head_stu=p_stu;
else
p_stu->stu_ps=*head_stu;
*head_stu=p_stu;
check_stu_class(p_stu,&head_cla);
}
void show_stu (struct student **head_stu) /*print the link of the student*/
{
struct student *k_stu;
k_stu=*head_stu;
while(k_stu)
{ puts("----------------------------------------");
puts("NUMBER:");
puts(k_stu->stu_number);
puts("NANE:");
puts(k_stu->stu_nam);
puts("SEX:");
puts(k_stu->stu_sex);
puts("AGE:");
puts(k_stu->stu_age);
puts("ID:");
puts(k_stu->stu_id);
puts("TEL:");
puts(k_stu->stu_tel);
puts("CLASS:");
printf("%s %s/n",k_stu->stu_major,k_stu->stu_class_num);
puts("ONLYNUMBER OF CLASS:");
puts(k_stu->classnumber);
k_stu=k_stu->stu_ps;
}
}
/********************************************************/
/*************************** the function of dorm******************************/
void create_dorm (struct dorm ** head_dorm,struct dorm * p_dorm)
{
p_dorm=(struct dorm *)malloc (sizeof(struct dorm));
puts("input the name of the campus:");
gets(p_dorm->dorm_campus_nam);
puts("input the number of build:");
scanf("%d",&(p_dorm->dorm_build_num));
getchar();
puts("input the number of the dorm:");
gets(p_dorm->dorm_num);
puts("input the mode of the dorm:");
gets(p_dorm->dorm_mode);
puts("input the net condition of the dorm:");
gets(p_dorm->dorm_internet);
puts("input the tel of the dorm:");
gets(p_dorm->dorm_tel);
puts("input the number of the student:");
scanf("%d",&(p_dorm->dorm_stu_num));
getchar();
puts("input the conditon of the dorm:");
scanf("%d",&(p_dorm->dorm_good));
p_dorm->pd=NULL;
p_dorm->ps=NULL;
if(*head_dorm==NULL)
*head_dorm=p_dorm;
else
p_dorm->pd=*head_dorm; /*sheng lai zhi bi*/
*head_dorm=p_dorm;
}
void show_dorm (struct dorm **head_dorm) /*print the link of the dorm*/
{
struct dorm * k_dorm;
k_dorm=*head_dorm;
while(k_dorm)
{ puts("------------drom----------------------");
puts("CAMPUS NAME:");
puts(k_dorm->dorm_campus_nam);
puts("BUILDINT NUMBER:");
printf("%d/n",k_dorm->dorm_build_num);
puts("DORM NUMBER:");
puts(k_dorm->dorm_num);
puts("DORM MODE:");
puts(k_dorm->dorm_mode);
puts("INTERNET:");
puts(k_dorm->dorm_internet);
puts("TEL:");
puts(k_dorm->dorm_tel);
puts("NUMBER OF STUDENT:");
printf("%d/n",k_dorm->dorm_stu_num);
puts("CONDITION OF THE DORM:");
printf("%d/n",k_dorm->dorm_good);
getchar();
k_dorm=k_dorm->pd;
}
}
/************************ the function of teacher *************/
void create_tea (struct teacher **head_tea,struct teacher *p_tea)
{
p_tea=(struct teacher *)malloc(sizeof(struct teacher));
puts("input the name of the teacher:");
gets(p_tea->teacher_nam);
puts("input the number of the teacher:");
gets(p_tea->teacher_number);
puts("input the sex of teacher:");
gets(p_tea->teacher_sex);
puts("input the birthday of the teacher:");
gets(p_tea->teacher_birth);
puts("input the ID number:");
gets(p_tea->teacher_id);
puts("input the level of the teacher:");
gets(p_tea->teacher_mode);
puts("input the tel of the teacher:");
gets(p_tea->teacher_tel);
puts("input the year salary:");
scanf("%d",&(p_tea->teacher_salary));
getchar();
p_tea->tea_pc=NULL;
p_tea->tea_pt=NULL;
if(*head_tea==NULL)
*head_tea=p_tea;
else
{
p_tea->tea_pt=*head_tea;
*head_tea=p_tea;
}
}
void show_tea (struct teacher **head_tea)
{
struct teacher * k_tea;
k_tea=*head_tea;
while(k_tea)
{
puts("----------------------------");
puts("NAME:");
puts(k_tea->teacher_nam);
puts("NUMBER:");
puts(k_tea->teacher_number);
puts("SEX:");
puts(k_tea->teacher_sex);
puts("BIRTHDAY:");
puts(k_tea->teacher_birth);
puts("ID:");
puts(k_tea->teacher_id);
puts("LEVEL:");
puts(k_tea->teacher_mode);
puts("TEL:");
puts(k_tea->teacher_tel);
puts("SALARY:");
printf("%d/n",k_tea->teacher_salary);
getchar();
k_tea=k_tea->tea_pt;
}
}
/**************** the function of the course*********************/
void create_cou (struct course ** head_cou,struct course * p_cou)
{
p_cou=(struct course *)malloc(sizeof(struct course));
puts("input the only number of the course:");
gets(p_cou->course_number);
puts("input the name of the course:");
gets(p_cou->course_nam);
puts("input the time of the course like 2004-2005:");
gets(p_cou->course_date);
p_cou->course_pt=NULL;
p_cou->course_pc=NULL;
if (*head_cou==NULL)
*head_cou=p_cou;
else
{
p_cou->course_pc=*head_cou;
*head_cou=p_cou;
}
}
void show_cou (struct course ** head_cou)
{
struct course * k_cou;
k_cou=*head_cou;
while(k_cou)
{
puts("ONLY NUMBER:");
puts(k_cou->course_number);
puts("NAME:");
puts(k_cou->course_nam);
puts("DATE:");
puts(k_cou->course_date);
k_cou=k_cou->course_pc;
}
}
/**************** the function of the yuanxi *************/
void create_yua (struct yuanxi ** head_yua,struct yuanxi *p_yua)
{
p_yua=(struct yuanxi *)malloc (sizeof(struct yuanxi));
puts("input the only number of the yuanxi:");
gets(p_yua->yuanxi_number);
puts("input the name of the yuanxi:");
gets(p_yua->yuanxi_nam);
puts("input the name of the headmaster:");
gets(p_yua->yuanxi_headmaster);
p_yua->yuanxi_py=NULL;
p_yua->yuanxi_pc=NULL;
p_yua->yuanxi_pt=NULL;
p_yua->yuanxi_pm=NULL;
if(*head_yua==NULL)
*head_yua=p_yua;
else
{
p_yua->yuanxi_py=*head_yua;
*head_yua=p_yua;
}
}
void show_yua (struct yuanxi ** head_yua)
{
struct yuanxi *k_yua;
k_yua=*head_yua;
while(k_yua)
{
puts("-----------------------------");
puts("ONLY NUMBER:");
puts(k_yua->yuanxi_number);
puts("NAME:");
puts(k_yua->yuanxi_nam);
puts("HEADMASTER:");
puts(k_yua->yuanxi_headmaster);
getchar();
k_yua=k_yua->yuanxi_py;
}
}
void create_major_yuanxi(struct major * p_maj,struct yuanxi *p_yua)
{
if(p_yua->yuanxi_pm==NULL)
p_yua->yuanxi_pm=p_maj;
else
{
p_maj->major_yuanxi_pm=p_yua->yuanxi_pm;
p_yua->yuanxi_pm=p_maj;
}
}
/*************** the function of the class**********************/
void create_cla (struct class ** head_cla,struct class * p_cla)
{
p_cla=(struct class *)malloc (sizeof(struct class));
puts("input the major:");
gets(p_cla->class_major);
puts("input the number of the class:");
gets(p_cla->class_num);
puts("input the master of the class:");
gets(p_cla->class_master_nam);
puts("input his number:");
gets(p_cla->class_master_num);
puts("input the only number of the class:");
gets(p_cla->class_number);
p_cla->class_ps=NULL;
p_cla->pc=NULL;
p_cla->class_pm=NULL;
p_cla->major_pc=NULL;
if(*head_cla==NULL)
*head_cla=p_cla;
else
{
p_cla->pc=*head_cla;
*head_cla=p_cla;
}
check_class_major(p_cla,&head_maj);
}
void create_stu_class(struct student *p_stu,struct class *p_cla) /*the function will be used in the struct class*/
{
if(p_cla->class_ps==NULL)
p_cla->class_ps=p_stu;
else
{
p_stu->stu_class_ps=p_cla->class_ps;
p_cla->class_ps=p_stu;
}
p_stu->stu_class_pc=p_cla;
}
/**************************the function of the major******************************/
void create_maj (struct major ** head_maj,struct major * p_maj)
{
p_maj=(struct major *)malloc(sizeof(struct major));
puts("input the name of the major:");
gets(p_maj->major_nam);
puts("input the number of the major:");
gets(p_maj->major_num);
puts("input the name of the yuanxi:");
gets(p_maj->major_yuanxi_nam);
p_maj->pm=NULL;
p_maj->major_pc=NULL;
p_maj->major_yuanxi_pm=NULL;
if(*head_maj==NULL)
*head_maj=p_maj;
else
{
p_maj->pm=*head_maj;
*head_maj=p_maj;
}
check_major_yuanxi(p_maj,&head_yua);
}
void show_maj (struct major ** head_maj)
{
struct major* k_maj;
k_maj= * head_maj;
while (k_maj)
{
puts(k_maj->major_nam);
k_maj=k_maj->pm;
}
}
void create_class_major(struct class * p_cla,struct major * p_maj ) /*create class chain in major struct*/
{
if(p_maj->major_pc==NULL)
p_maj->major_pc=p_cla;
else
{
p_cla->major_pc=p_maj->major_pc;
p_maj->major_pc=p_cla;
}
p_cla->class_pm=p_maj;
}
/************************** the function of the connect each chain *************************************************************************************/
void check_stu_class (struct student * p_stu,struct class * *head_cla) /*create a student in the class when you input a student*/
{
int tag=1;
struct class* k_cla;
k_cla= * head_cla;
while(k_cla)
{
if(strcmp(k_cla->class_major,p_stu->stu_major)==0)
if(strcmp(k_cla->class_num,p_stu->stu_class_num)==0)
{
create_stu_class(p_stu,k_cla);
tag=0;
puts("Ok!");
}
k_cla=k_cla->pc;
}
if(tag)
puts("No class exist!");
}
void check_class_major(struct class * p_cla,struct major ** head_major )
{
int tag=1;
struct major* k_maj;
k_maj= * head_major;
while(k_maj)
{
if(strcmp(k_maj->major_nam,p_cla->class_major)==0)
{
create_class_major(p_cla,k_maj);
tag=0;
puts("Ok!");
}
k_maj=k_maj->pm;
}
if(tag)
puts("No major exist!");
}
void check_major_yuanxi(struct major * p_maj,struct yuanxi **head_yua)
{
int tag=1;
struct yuanxi *k_yua;
k_yua=*head_yua;
while(k_yua)
{
if(strcmp(k_yua->yuanxi_nam,p_maj->major_yuanxi_nam)==0)
{
create_major_yuanxi(p_maj,k_yua);
tag=0;
break;
}
k_yua=k_yua->yuanxi_py;
}
if(tag)
puts("No yuanxi exist!");
else
puts("Ok!");
}
/************ xuanke ************/
int choose_course (struct stu_course *p_stu_cou)
{
int tag1=1;
int tag2=1;
char cc_stu_number[LENGTH_STU_NUMBER];
char cc_cou_number[LENGTH_COURSE_NUMBER];
struct student *k_stu;
struct course *k_cou;
puts("input the number of the student :");
gets(cc_stu_number);
puts("input the number of the course :");
gets(cc_cou_number);
k_stu=head_stu; /*check if there is the student*/
while(k_stu)
{
if(strcmp(k_stu->stu_number,cc_stu_number)==0)
{
puts("the student :");
puts(k_stu->stu_nam);
tag1=0;
break;
}
k_stu=k_stu->stu_ps;
}
if(tag1)
{
puts("The student is not exist.");
getchar();
return (0);
}
k_cou=head_cou; /*check if there is the course*/
while(k_cou)
{
if(strcmp(k_cou->course_number,cc_cou_number)==0)
{
puts("the student :");
puts(k_cou->course_nam);
tag2=0;
break;
}
k_cou=k_cou->course_pc;
}
if(tag2)
{
puts("The course is not exist.");
getchar();
return (0);
}
p_stu_cou=(struct stu_course *)malloc(sizeof(struct stu_course));
strcpy(p_stu_cou->stu_course_number,k_cou->course_number);
puts("the number of the course:");
puts(p_stu_cou->stu_course_number);
strcpy(p_stu_cou->stu_course_stu_number,k_stu->stu_number);
puts("the number of the student:");
puts(p_stu_cou->stu_course_stu_number);
getchar();
p_stu_cou->cour=k_cou;
puts("The name of the course:");
puts(p_stu_cou->cour->course_nam);
p_stu_cou->pss=k_stu;
puts("The name of the student:");
puts(p_stu_cou->pss->stu_nam);
p_stu_cou->psc=NULL;
getchar();
if(k_stu->stu_pc==NULL)
k_stu->stu_pc=p_stu_cou;
else
{
p_stu_cou->psc=k_stu->stu_pc;
k_stu->stu_pc=p_stu_cou;
}
create_stu_cou(&head_stu_cou,p_stu_cou);
puts("Ok!");
return (1);
}
int test_course (void)
{
char cc_stu_number[LENGTH_STU_NUMBER];
struct student * k_stu;
struct stu_course *k_stu_cou;
puts("input the number of student you want to know:");
gets(cc_stu_number);
k_stu=head_stu;
while(k_stu)
{
if(strcmp(cc_stu_number,k_stu->stu_number)==0)
{
puts("the student:");
puts(k_stu->stu_nam);
getchar();
break;
}
k_stu=k_stu->stu_ps;
}
if(k_stu==NULL)
{
puts("No student!");
return (0);
}
else
{
puts("the course of the student:");
k_stu_cou=k_stu->stu_pc;
while(k_stu_cou)
{
puts(" Name:");
puts(k_stu_cou->cour->course_nam);
puts(" Number:");
puts(k_stu_cou->cour->course_number);
puts(" Date:");
puts(k_stu_cou->cour->course_date);
getchar();
k_stu_cou=k_stu_cou->psc;
}
}
return (1);
}
int choose_course_yuanxi (struct stu_course *p_stu_cou)
{
char cc_yua_name[LENGTH_YUANXI_NAME];
char cc_cou_number[LENGTH_COURSE_NUMBER];
struct yuanxi* k_yua;
struct course* k_cou;
struct major* k_maj;
struct class* k_cla;
struct student* k_stu;
puts("input the name of the yuanxi:"); /* this place may change to number or others */
gets(cc_yua_name);
puts("input the number of the course:");
gets(cc_cou_number);
k_yua=head_yua;
while(k_yua)
{
if(strcmp(cc_yua_name,k_yua->yuanxi_nam)==0)
{
puts("the yuanxi:");
puts(k_yua->yuanxi_nam);
break;
}
k_yua=k_yua->yuanxi_py;
}
if(k_yua==NULL)
{
puts("the yuanxi is not existed.");
getchar();
return(0);
}
k_cou=head_cou;
while(k_cou)
{
if(strcmp(cc_cou_number,k_cou->course_number)==0)
{
puts("the course:");
puts(k_cou->course_nam);
getchar();
break;
}
if(k_cou==NULL)
{
puts("the course is not existed.");
getchar();
return(0);
}
k_cou=k_cou->course_pc;
}
k_maj=k_yua->yuanxi_pm;
while(k_maj)
{
k_cla=k_maj->major_pc;
while(k_cla)
{
k_stu=k_cla->class_ps;
while(k_stu)
{
p_stu_cou=(struct stu_course *)malloc(sizeof(struct stu_course));
strcpy(p_stu_cou->stu_course_number,k_cou->course_number);
strcpy(p_stu_cou->stu_course_number,k_stu->stu_number);
p_stu_cou->cour=k_cou;
p_stu_cou->pss=k_stu;
p_stu_cou->psc=NULL;
p_stu_cou->stu_course_psc=NULL;
if(k_stu->stu_pc==NULL)
k_stu->stu_pc=p_stu_cou;
else
{
p_stu_cou->psc=k_stu->stu_pc;
k_stu->stu_pc=p_stu_cou;
}
puts("Finish:");
puts(k_stu->stu_nam);
create_stu_cou(&head_stu_cou,p_stu_cou);
getchar();
k_stu=k_stu->stu_class_ps;
p_stu_cou=NULL;
}
puts("Finish the class.");
printf("%s %s/n",k_cla->class_major,k_cla->class_num);
k_cla=k_cla->major_pc;
}
puts("Finish the major.");
puts(k_maj->major_nam);
k_maj=k_maj->major_yuanxi_pm;
}
}
int choose_course_major (struct stu_course *p_stu_cou)
{
char cc_maj_name[LENGTH_MAJOR_NAM];
char cc_cou_number[LENGTH_COURSE_NUMBER];
struct major *k_maj;
struct course *k_cou;
struct class *k_cla;
struct student *k_stu;
puts("input the name of the major:");
gets(cc_maj_name);
puts("input the number of the course:");
gets(cc_cou_number);
k_maj=head_maj;
while(k_maj)
{
if(strcmp(cc_maj_name,k_maj->major_nam)==0)
{
puts("the major:");
puts(k_maj->major_nam);
getchar();
break;
}
k_maj=k_maj->pm;
}
if(k_maj==NULL)
{
puts("the major is not existed.");
getchar();
return (0);
}
k_cou=head_cou;
while(k_cou)
{
if(strcmp(cc_cou_number,k_cou->course_number)==0)
{
puts("the course:");
puts(k_cou->course_nam);
getchar();
break;
}
k_cou=k_cou->course_pc;
}
if(k_cou==NULL)
{
puts("the course is not existed.");
getchar();
return (0);
}
k_cla=k_maj->major_pc;
while(k_cla)
{
k_stu=k_cla->class_ps;
while(k_stu)
{
p_stu_cou=(struct stu_course *)malloc(sizeof(struct stu_course));
strcpy(p_stu_cou->stu_course_number,cc_cou_number);
strcpy(p_stu_cou->stu_course_stu_number,k_stu->stu_number);
p_stu_cou->cour=k_cou;
p_stu_cou->pss=k_stu;
p_stu_cou->psc=NULL;
p_stu_cou->stu_course_psc=NULL;
if(k_stu->stu_pc==NULL)
k_stu->stu_pc=p_stu_cou;
else
{
p_stu_cou->psc=k_stu->stu_pc;
k_stu->stu_pc=p_stu_cou;
}
puts("Finish:");
puts(k_stu->stu_nam);
create_stu_cou(&head_stu_cou,p_stu_cou);
getchar();
k_stu=k_stu->stu_class_ps;
p_stu_cou=NULL;
}
puts("Finish the class.");
printf("%s %s/n",k_cla->class_major,k_cla->class_num);
k_cla=k_cla->major_pc;
}
}
void create_stu_cou (struct stu_course **head_stu_cou,struct stu_course *p_stu_cou)
{
p_stu_cou->mark=-1;
if(*head_stu_cou==NULL)
*head_stu_cou=p_stu_cou;
else
{
p_stu_cou->stu_course_psc=*head_stu_cou;
*head_stu_cou=p_stu_cou;
}
}
/********* write mark *****************/
int write_mark (struct stu_course *head_stu_cou)
{
int tag=0;
char cc_cou_number[LENGTH_COURSE_NUMBER];
struct stu_course *k_stu_cou;
puts("input the number of the course:");
gets(cc_cou_number);
k_stu_cou=head_stu_cou;
while(k_stu_cou)
{
if(strcmp(cc_cou_number,k_stu_cou->stu_course_number)==0)
{
if(k_stu_cou->mark==-1)
puts("the mark is written first.");
printf("%s/t%s/t",cc_cou_number,k_stu_cou->pss->stu_nam);
scanf("%d",&(k_stu_cou->mark));
getchar();
tag=1;
}
k_stu_cou=k_stu_cou->stu_course_psc;
}
if(tag==0)
{
puts("the course is not existed or nobody choose the course.");
getchar();
return (0);
}
else
{
puts("the work is over.");
getchar ();
return (1);
}
}
int check_mark (struct student *head_stu)
{
int tag=0;
char cc_stu_number[LENGTH_STU_NUMBER];
struct student *k_stu;
struct stu_course *k_stu_cou;
puts("input the number of the student:");
gets(cc_stu_number);
k_stu=head_stu;
while(k_stu)
{
if(strcmp(cc_stu_number,k_stu->stu_number)==0)
{
k_stu_cou=k_stu->stu_pc;
if(k_stu_cou==NULL)
{
puts("the student havn't chosed any course.");
getchar();
return (0);
}
else
{
printf("%s/t%s/n",k_stu->stu_number,k_stu->stu_nam);
while(k_stu_cou)
{
if(k_stu_cou->mark==-1)
{
printf("%s %s",k_stu_cou->stu_course_number,k_stu_cou->cour->course_nam);
printf(" %s/n","No mark");
}
else
{
printf("%s %s %d/n",k_stu_cou->stu_course_number,k_stu_cou->cour->course_nam,k_stu_cou->mark);
}
k_stu_cou=k_stu_cou->psc;
}
puts("-------------------------------------------");
getchar();
return (1);
}
}
tag=1;
k_stu=k_stu->stu_ps;
}
if(tag==0)
{
puts("the student is not existed'");
getchar();
return (0);
}
}
#include <stdlib.h>
/*********************************/
#define LENGTH_STU_COURSE_NUMBER 16
#define LENGTH_CLASS_MAJOR 26
#define LENGTH_CLASS_NUMBER 16
#define LENGTH_CLASS_MASTER_NAM 16
#define LENGTH_CLASS_MASTER_NUM 16
#define LENGTH_CLASS_NUMBER 16
#define LENGTH_CLASS_NUM 7
#define LENGTH_CLASS_YUANXI 16
#define LENGTH_STU_NAM 16
#define LENGTH_STU_NUMBER 16
#define LENGTH_STU_SEX 11
#define LENGTH_STU_TEL 16
#define LENGTH_STU_AGE 3
#define LENGTH_STU_CLASSNUMBER 16
#define LENGTH_STU_MAJOR 26
#define LENGTH_STU_CLASS_NUM 5
#define LENGTH_STU_COURSE 15
#define LENGTH_STU_ID 20
#define LENGTH_DORM_CAMPUS_NAM 16
#define LENGTH_DORM_NUM 5
#define LENGTH_DORM_MODE 21
#define LENGTH_DORM_NET 4
#define LENGTH_DORM_TEL 16
#define LENGTH_DORM_NUMBER 16
#define LENGTH_COURSE_NUMBER 16
#define LENGTH_COURSE_NAM 16
#define LENGTH_COURSE_DATE 12
#define LENGTH_TEACHER_NAM 16
#define LENGTH_TEACHER_NUM 16
#define LENGTH_TEACHER_SEX 11
#define LENGTH_TEACHER_BIRTH 11
#define LENGTH_TEACHER_MODE 21
#define LENGTH_TEACHER_TEL 16
#define LENGTH_TEACHER_NUMBER 16
#define LENGTH_TEACHER_ID 20
#define LENGTH_YUANXI_NUMBER 16
#define LENGTH_YUANXI_NAME 26
#define LENGTH_YUANXI_HEADMASTER 26
#define LENGTH_MAJOR_NAM 26
#define LENGTH_MAJOR_NUMBER 16
#define LENGTH_MAJOR_YUANXI_NAM 26
#define PASSWORD 16
/*********************************/
struct student * head_stu;
struct student *p_stu;
struct dorm *head_dorm;
struct dorm *p_dorm;
struct teacher * head_tea;
struct teacher *p_tea;
struct course *head_cou;
struct course *p_cou;
struct yuanxi *head_yua;
struct yuanxi *p_yua;
struct class *head_cla;
struct class *p_cla;
struct major *head_maj;
struct major *p_maj;
struct stu_course *head_stu_cou;
struct stu_course *p_stu_cou;
/*********************************/
struct yuanxi
{
char yuanxi_number[LENGTH_YUANXI_NUMBER];
char yuanxi_nam[LENGTH_YUANXI_NAME];
char yuanxi_headmaster[LENGTH_YUANXI_HEADMASTER];
struct teacher * yuanxi_pt; /*这是用来记录院系负责人的指针*/
struct yuanxi * yuanxi_py; /*指向下个院系*/
struct class * yuanxi_pc; /*指向开始的班级*/
struct major *yuanxi_pm; /*the pionter used to create a chain of major in a struct yuanxi*/
};
struct class
{
char class_yuanxi[LENGTH_CLASS_YUANXI];
char class_major[LENGTH_CLASS_MAJOR];
char class_num[LENGTH_CLASS_NUM]; /*the number used in major*/ /*这几个可以合起来得出班级的唯一标识*/
char class_master_nam[LENGTH_CLASS_MASTER_NAM];
char class_master_num[LENGTH_CLASS_MASTER_NUM];
char class_number[LENGTH_CLASS_NUMBER]; /*the only one sign used in the files*/
struct student *class_ps; /*the pointer of student used in the class*/
struct class *pc;
struct major * class_pm;
struct class *major_pc; /*the pionter will be used in the struct major*/
};
struct teacher
{
char teacher_nam [LENGTH_TEACHER_NAM];
char teacher_sex[LENGTH_TEACHER_SEX];
char teacher_birth[LENGTH_TEACHER_BIRTH];
char teacher_mode[LENGTH_TEACHER_MODE];
char teacher_tel[LENGTH_TEACHER_TEL];
char teacher_number[LENGTH_TEACHER_NUMBER]; /*the only sign of the teacher*/
char teacher_course_number[LENGTH_COURSE_NUMBER];
char teacher_id[LENGTH_TEACHER_ID];
char teacher_password[PASSWORD];
int teacher_salary;
struct course * tea_pc; /*the pionter to the teacher of the course*/
struct teacher *tea_pt; /*the pionter used in the chain of the teacher*/
};
struct dorm
{
char dorm_campus_nam[LENGTH_DORM_CAMPUS_NAM];
int dorm_build_num;
char dorm_num[LENGTH_DORM_NUM];
char dorm_mode[LENGTH_DORM_MODE];
char dorm_internet[LENGTH_DORM_NET];
char dorm_tel[LENGTH_DORM_TEL];
char dorm_number[LENGTH_DORM_NUMBER]; /*the only sign of the dorm*/
int dorm_stu_num;
int dorm_good;
struct dorm *pd; /*the pionter to a dorm used in the chain of the dorm*/
struct student * ps; /*the pionter to a student in the chain of the student */
};
struct course
{
char course_number[LENGTH_COURSE_NUMBER]; /*the only sign of the course*/
char course_nam[LENGTH_COURSE_NAM];
char course_date[LENGTH_COURSE_DATE];
struct teacher * course_pt; /*the pionter to a teacher in the chain of the teacher*/
struct course *course_pc;
};
struct stu_course
{
char stu_course_number[LENGTH_COURSE_NUMBER];
char stu_course_stu_number[LENGTH_STU_NUMBER];
struct course *cour; /*the pionter to a course in the chain of the struct of student*/
struct student *pss; /*the pionter to a student who learn the course*/
struct stu_course * psc; /*the pointer to a stu_course in the chain of the stu_course*/
struct stu_course * stu_course_psc; /*the pionter to the chain of the stu_course*/
int mark;
};
struct student
{
char stu_number[LENGTH_STU_NUMBER];
char stu_nam[LENGTH_STU_NAM];
char stu_sex[LENGTH_STU_SEX];
char stu_age[LENGTH_STU_AGE];
char stu_tel[LENGTH_STU_TEL];
char stu_major[LENGTH_STU_MAJOR];
char stu_class_num[LENGTH_STU_CLASS_NUM];
char classnumber[LENGTH_STU_CLASSNUMBER]; /*the only one sign of the class used in files*/
char stu_dorm_number[LENGTH_DORM_NUMBER]; /*the number of dorm will be used in the recreate the chain, and will
be made by the other */
char stu_id[LENGTH_STU_ID];
char stu_password[PASSWORD];
struct class *stu_class_pc; /*the pointer to the class*/
struct stu_course *stu_pc; /*the chain of the courses student chosed*/
struct dorm * stu_dorm; /*the dorm the student lived*/
struct student * stu_dorm_ps; /*the pointer of the student used in the struct of the dorm*/
struct student * stu_ps; /*the pointer of the student used in the chain of the student*/
struct student * stu_class_ps; /*the pointer used in class chain*/
};
struct major
{
char major_nam[LENGTH_MAJOR_NAM];
char major_yuanxi_nam[LENGTH_MAJOR_NAM];
char major_num[LENGTH_MAJOR_NUMBER];
struct major * major_yuanxi_pm; /* !!!!!!!!!!! ----repeat-----!!!!!!!!! */
struct major * pm;
struct class * major_pc;
};
/**********************************/
void create_stu (struct student **,struct student *);
void show_stu (struct student **);
void create_dorm (struct dorm **,struct dorm *);
void show_dorm (struct dorm **);
void create_tea(struct teacher **,struct teacher *);
void show_tea(struct teacher **);
void create_cou (struct course **,struct course *);
void show_cou (struct course **);
void create_yua (struct yuanxi **,struct yuanxi *);
void show_yua (struct yuanxi **);
void create_cla (struct class **,struct class *);
void create_maj(struct major**,struct major *);
void show_maj (struct major **);
void create_stu_cou(struct stu_course **,struct stu_course *);
void main_menu (void);
void add_menu (void);
void show_menu (void);
void choose_menu (void);
void create_stu_class (struct student *,struct class *); /*put the student in the chain in struct class*/
void check_stu_class (struct student *,struct class **); /*when you input a student,put it to the chain in struct class which have been created*/
void create_class_major(struct class*,struct major *);
void check_class_major(struct class *,struct major **);
void create_major_yuanxi(struct major *,struct yuanxi *);
void check_major_yuanxi(struct major *,struct yuanxi **);
int choose_course (struct stu_course *);
int test_course (void);
int choose_course_yuanxi (struct stu_course *);
int choose_course_major (struct stu_course *p_stu_cou);
int write_mark (struct stu_course *);
int check_mark (struct student *);
/**********************************/
void main (void)
{
char cc;
int tag=1;
while(tag)
{
main_menu();
}
getchar();
}
/********************************** function used in all *********************/
void main_menu (void)
{
char main_c;
puts("+++++++++++++++MENU++++++++++++");
puts(" 1.Add.");
puts(" 2.Show.");
puts(" 3.Xuanke.");
puts(" 4.Test.");
puts(" 5.Exit.");
main_c=getch();
switch(main_c)
{
case '1':
add_menu();
break;
case '2':
show_menu();
break;
case '3':
choose_menu();
break;
case '4':
test_course();
break;
case '5':
exit(0);
default :
break;
}
}
void add_menu (void)
{
char add_c;
puts("+++++++++++++++MENU++++++++++++");
puts(" 1.Add Student.");
puts(" 2.Add Dorm.");
puts(" 3.Add Teacher.");
puts(" 4.Add Course.");
puts(" 5.Add Yuanxi.");
puts(" 6.Add Major");
puts(" 7.Add Cla");
add_c=getch();
switch(add_c)
{
case '1':
create_stu(&head_stu,p_stu);
break;
case '2':
create_dorm(&head_dorm,p_dorm);
break;
case '3':
create_tea(&head_tea,p_tea);
break;
case '4':
create_cou(&head_cou,p_cou);
break;
case '5':
create_yua(&head_yua,p_yua);
break;
case '6':
create_maj(&head_maj,p_maj); puts("Ok!");
break;
case '7':
create_cla(&head_cla,p_cla);
break;
}
}
void show_menu (void)
{
char show_c;
puts("+++++++++++++++MENU++++++++++++");
puts(" 1.Show Student.");
puts(" 2.Show Dorm.");
puts(" 3.Show Teacher.");
puts(" 4.Show Course.");
puts(" 5.Show Yuanxi.");
puts(" 6.Show Major.");
show_c=getch();
switch(show_c)
{
case '1':
show_stu(&head_stu);
break;
case '2':
show_dorm(&head_dorm);
break;
case '3':
show_tea(&head_tea);
break;
case '4':
show_cou(&head_cou);
break;
case '5':
show_yua(&head_yua);
break;
case '6':
show_maj(&head_maj);
break;
}
}
void choose_menu (void)
{
char c_choose;
puts("--------choose the course---------");
puts(" 1.student.");
puts(" 2.yuanxi.");
puts(" 3.major.");
puts(" 4.write mark.");
puts(" 5.check mark.");
c_choose=getch();
switch(c_choose)
{
case '1':
choose_course(p_stu_cou);
break;
case '2':
choose_course_yuanxi(p_stu_cou);
break;
case '3':
choose_course_major(p_stu_cou);
break;
case '4':
write_mark(head_stu_cou);
break;
case '5':
check_mark(head_stu);
break;
default:
break;
}
}
/*************************** the function of the student*******************************/
void create_stu (struct student **head_stu,struct student *p_stu) /*the function to add a node of the link of the student*/
{
p_stu=(struct student *)malloc (sizeof(struct student));
puts("input the number of the student:");
gets(p_stu->stu_number);
puts("input the name of the student:");
gets(p_stu->stu_nam);
puts("input the sex of the student:");
gets(p_stu->stu_sex);
puts("input the age of the student:");
gets(p_stu->stu_age);
puts("input the ID of the student:");
gets(p_stu->stu_id);
puts("input the tel of the student:");
gets(p_stu->stu_tel);
puts("input the major of the student:");
gets(p_stu->stu_major);
puts("input the class number of the student:");
gets(p_stu->stu_class_num);
puts("input the onlynumber of the class:");
gets(p_stu->classnumber);
p_stu->stu_class_pc=NULL; /*the pointer to the class*/
p_stu->stu_pc=NULL; /*the chain of the courses student chosed*/
p_stu->stu_dorm=NULL; /*the dorm the student lived*/
p_stu->stu_dorm_ps=NULL; /*the pointer of the student used in the struct of the dorm*/
p_stu->stu_ps=NULL; /*the pointer of the student used in the chain of the student*/
p_stu->stu_class_ps=NULL;
if(*head_stu==NULL)
*head_stu=p_stu;
else
p_stu->stu_ps=*head_stu;
*head_stu=p_stu;
check_stu_class(p_stu,&head_cla);
}
void show_stu (struct student **head_stu) /*print the link of the student*/
{
struct student *k_stu;
k_stu=*head_stu;
while(k_stu)
{ puts("----------------------------------------");
puts("NUMBER:");
puts(k_stu->stu_number);
puts("NANE:");
puts(k_stu->stu_nam);
puts("SEX:");
puts(k_stu->stu_sex);
puts("AGE:");
puts(k_stu->stu_age);
puts("ID:");
puts(k_stu->stu_id);
puts("TEL:");
puts(k_stu->stu_tel);
puts("CLASS:");
printf("%s %s/n",k_stu->stu_major,k_stu->stu_class_num);
puts("ONLYNUMBER OF CLASS:");
puts(k_stu->classnumber);
k_stu=k_stu->stu_ps;
}
}
/********************************************************/
/*************************** the function of dorm******************************/
void create_dorm (struct dorm ** head_dorm,struct dorm * p_dorm)
{
p_dorm=(struct dorm *)malloc (sizeof(struct dorm));
puts("input the name of the campus:");
gets(p_dorm->dorm_campus_nam);
puts("input the number of build:");
scanf("%d",&(p_dorm->dorm_build_num));
getchar();
puts("input the number of the dorm:");
gets(p_dorm->dorm_num);
puts("input the mode of the dorm:");
gets(p_dorm->dorm_mode);
puts("input the net condition of the dorm:");
gets(p_dorm->dorm_internet);
puts("input the tel of the dorm:");
gets(p_dorm->dorm_tel);
puts("input the number of the student:");
scanf("%d",&(p_dorm->dorm_stu_num));
getchar();
puts("input the conditon of the dorm:");
scanf("%d",&(p_dorm->dorm_good));
p_dorm->pd=NULL;
p_dorm->ps=NULL;
if(*head_dorm==NULL)
*head_dorm=p_dorm;
else
p_dorm->pd=*head_dorm; /*sheng lai zhi bi*/
*head_dorm=p_dorm;
}
void show_dorm (struct dorm **head_dorm) /*print the link of the dorm*/
{
struct dorm * k_dorm;
k_dorm=*head_dorm;
while(k_dorm)
{ puts("------------drom----------------------");
puts("CAMPUS NAME:");
puts(k_dorm->dorm_campus_nam);
puts("BUILDINT NUMBER:");
printf("%d/n",k_dorm->dorm_build_num);
puts("DORM NUMBER:");
puts(k_dorm->dorm_num);
puts("DORM MODE:");
puts(k_dorm->dorm_mode);
puts("INTERNET:");
puts(k_dorm->dorm_internet);
puts("TEL:");
puts(k_dorm->dorm_tel);
puts("NUMBER OF STUDENT:");
printf("%d/n",k_dorm->dorm_stu_num);
puts("CONDITION OF THE DORM:");
printf("%d/n",k_dorm->dorm_good);
getchar();
k_dorm=k_dorm->pd;
}
}
/************************ the function of teacher *************/
void create_tea (struct teacher **head_tea,struct teacher *p_tea)
{
p_tea=(struct teacher *)malloc(sizeof(struct teacher));
puts("input the name of the teacher:");
gets(p_tea->teacher_nam);
puts("input the number of the teacher:");
gets(p_tea->teacher_number);
puts("input the sex of teacher:");
gets(p_tea->teacher_sex);
puts("input the birthday of the teacher:");
gets(p_tea->teacher_birth);
puts("input the ID number:");
gets(p_tea->teacher_id);
puts("input the level of the teacher:");
gets(p_tea->teacher_mode);
puts("input the tel of the teacher:");
gets(p_tea->teacher_tel);
puts("input the year salary:");
scanf("%d",&(p_tea->teacher_salary));
getchar();
p_tea->tea_pc=NULL;
p_tea->tea_pt=NULL;
if(*head_tea==NULL)
*head_tea=p_tea;
else
{
p_tea->tea_pt=*head_tea;
*head_tea=p_tea;
}
}
void show_tea (struct teacher **head_tea)
{
struct teacher * k_tea;
k_tea=*head_tea;
while(k_tea)
{
puts("----------------------------");
puts("NAME:");
puts(k_tea->teacher_nam);
puts("NUMBER:");
puts(k_tea->teacher_number);
puts("SEX:");
puts(k_tea->teacher_sex);
puts("BIRTHDAY:");
puts(k_tea->teacher_birth);
puts("ID:");
puts(k_tea->teacher_id);
puts("LEVEL:");
puts(k_tea->teacher_mode);
puts("TEL:");
puts(k_tea->teacher_tel);
puts("SALARY:");
printf("%d/n",k_tea->teacher_salary);
getchar();
k_tea=k_tea->tea_pt;
}
}
/**************** the function of the course*********************/
void create_cou (struct course ** head_cou,struct course * p_cou)
{
p_cou=(struct course *)malloc(sizeof(struct course));
puts("input the only number of the course:");
gets(p_cou->course_number);
puts("input the name of the course:");
gets(p_cou->course_nam);
puts("input the time of the course like 2004-2005:");
gets(p_cou->course_date);
p_cou->course_pt=NULL;
p_cou->course_pc=NULL;
if (*head_cou==NULL)
*head_cou=p_cou;
else
{
p_cou->course_pc=*head_cou;
*head_cou=p_cou;
}
}
void show_cou (struct course ** head_cou)
{
struct course * k_cou;
k_cou=*head_cou;
while(k_cou)
{
puts("ONLY NUMBER:");
puts(k_cou->course_number);
puts("NAME:");
puts(k_cou->course_nam);
puts("DATE:");
puts(k_cou->course_date);
k_cou=k_cou->course_pc;
}
}
/**************** the function of the yuanxi *************/
void create_yua (struct yuanxi ** head_yua,struct yuanxi *p_yua)
{
p_yua=(struct yuanxi *)malloc (sizeof(struct yuanxi));
puts("input the only number of the yuanxi:");
gets(p_yua->yuanxi_number);
puts("input the name of the yuanxi:");
gets(p_yua->yuanxi_nam);
puts("input the name of the headmaster:");
gets(p_yua->yuanxi_headmaster);
p_yua->yuanxi_py=NULL;
p_yua->yuanxi_pc=NULL;
p_yua->yuanxi_pt=NULL;
p_yua->yuanxi_pm=NULL;
if(*head_yua==NULL)
*head_yua=p_yua;
else
{
p_yua->yuanxi_py=*head_yua;
*head_yua=p_yua;
}
}
void show_yua (struct yuanxi ** head_yua)
{
struct yuanxi *k_yua;
k_yua=*head_yua;
while(k_yua)
{
puts("-----------------------------");
puts("ONLY NUMBER:");
puts(k_yua->yuanxi_number);
puts("NAME:");
puts(k_yua->yuanxi_nam);
puts("HEADMASTER:");
puts(k_yua->yuanxi_headmaster);
getchar();
k_yua=k_yua->yuanxi_py;
}
}
void create_major_yuanxi(struct major * p_maj,struct yuanxi *p_yua)
{
if(p_yua->yuanxi_pm==NULL)
p_yua->yuanxi_pm=p_maj;
else
{
p_maj->major_yuanxi_pm=p_yua->yuanxi_pm;
p_yua->yuanxi_pm=p_maj;
}
}
/*************** the function of the class**********************/
void create_cla (struct class ** head_cla,struct class * p_cla)
{
p_cla=(struct class *)malloc (sizeof(struct class));
puts("input the major:");
gets(p_cla->class_major);
puts("input the number of the class:");
gets(p_cla->class_num);
puts("input the master of the class:");
gets(p_cla->class_master_nam);
puts("input his number:");
gets(p_cla->class_master_num);
puts("input the only number of the class:");
gets(p_cla->class_number);
p_cla->class_ps=NULL;
p_cla->pc=NULL;
p_cla->class_pm=NULL;
p_cla->major_pc=NULL;
if(*head_cla==NULL)
*head_cla=p_cla;
else
{
p_cla->pc=*head_cla;
*head_cla=p_cla;
}
check_class_major(p_cla,&head_maj);
}
void create_stu_class(struct student *p_stu,struct class *p_cla) /*the function will be used in the struct class*/
{
if(p_cla->class_ps==NULL)
p_cla->class_ps=p_stu;
else
{
p_stu->stu_class_ps=p_cla->class_ps;
p_cla->class_ps=p_stu;
}
p_stu->stu_class_pc=p_cla;
}
/**************************the function of the major******************************/
void create_maj (struct major ** head_maj,struct major * p_maj)
{
p_maj=(struct major *)malloc(sizeof(struct major));
puts("input the name of the major:");
gets(p_maj->major_nam);
puts("input the number of the major:");
gets(p_maj->major_num);
puts("input the name of the yuanxi:");
gets(p_maj->major_yuanxi_nam);
p_maj->pm=NULL;
p_maj->major_pc=NULL;
p_maj->major_yuanxi_pm=NULL;
if(*head_maj==NULL)
*head_maj=p_maj;
else
{
p_maj->pm=*head_maj;
*head_maj=p_maj;
}
check_major_yuanxi(p_maj,&head_yua);
}
void show_maj (struct major ** head_maj)
{
struct major* k_maj;
k_maj= * head_maj;
while (k_maj)
{
puts(k_maj->major_nam);
k_maj=k_maj->pm;
}
}
void create_class_major(struct class * p_cla,struct major * p_maj ) /*create class chain in major struct*/
{
if(p_maj->major_pc==NULL)
p_maj->major_pc=p_cla;
else
{
p_cla->major_pc=p_maj->major_pc;
p_maj->major_pc=p_cla;
}
p_cla->class_pm=p_maj;
}
/************************** the function of the connect each chain *************************************************************************************/
void check_stu_class (struct student * p_stu,struct class * *head_cla) /*create a student in the class when you input a student*/
{
int tag=1;
struct class* k_cla;
k_cla= * head_cla;
while(k_cla)
{
if(strcmp(k_cla->class_major,p_stu->stu_major)==0)
if(strcmp(k_cla->class_num,p_stu->stu_class_num)==0)
{
create_stu_class(p_stu,k_cla);
tag=0;
puts("Ok!");
}
k_cla=k_cla->pc;
}
if(tag)
puts("No class exist!");
}
void check_class_major(struct class * p_cla,struct major ** head_major )
{
int tag=1;
struct major* k_maj;
k_maj= * head_major;
while(k_maj)
{
if(strcmp(k_maj->major_nam,p_cla->class_major)==0)
{
create_class_major(p_cla,k_maj);
tag=0;
puts("Ok!");
}
k_maj=k_maj->pm;
}
if(tag)
puts("No major exist!");
}
void check_major_yuanxi(struct major * p_maj,struct yuanxi **head_yua)
{
int tag=1;
struct yuanxi *k_yua;
k_yua=*head_yua;
while(k_yua)
{
if(strcmp(k_yua->yuanxi_nam,p_maj->major_yuanxi_nam)==0)
{
create_major_yuanxi(p_maj,k_yua);
tag=0;
break;
}
k_yua=k_yua->yuanxi_py;
}
if(tag)
puts("No yuanxi exist!");
else
puts("Ok!");
}
/************ xuanke ************/
int choose_course (struct stu_course *p_stu_cou)
{
int tag1=1;
int tag2=1;
char cc_stu_number[LENGTH_STU_NUMBER];
char cc_cou_number[LENGTH_COURSE_NUMBER];
struct student *k_stu;
struct course *k_cou;
puts("input the number of the student :");
gets(cc_stu_number);
puts("input the number of the course :");
gets(cc_cou_number);
k_stu=head_stu; /*check if there is the student*/
while(k_stu)
{
if(strcmp(k_stu->stu_number,cc_stu_number)==0)
{
puts("the student :");
puts(k_stu->stu_nam);
tag1=0;
break;
}
k_stu=k_stu->stu_ps;
}
if(tag1)
{
puts("The student is not exist.");
getchar();
return (0);
}
k_cou=head_cou; /*check if there is the course*/
while(k_cou)
{
if(strcmp(k_cou->course_number,cc_cou_number)==0)
{
puts("the student :");
puts(k_cou->course_nam);
tag2=0;
break;
}
k_cou=k_cou->course_pc;
}
if(tag2)
{
puts("The course is not exist.");
getchar();
return (0);
}
p_stu_cou=(struct stu_course *)malloc(sizeof(struct stu_course));
strcpy(p_stu_cou->stu_course_number,k_cou->course_number);
puts("the number of the course:");
puts(p_stu_cou->stu_course_number);
strcpy(p_stu_cou->stu_course_stu_number,k_stu->stu_number);
puts("the number of the student:");
puts(p_stu_cou->stu_course_stu_number);
getchar();
p_stu_cou->cour=k_cou;
puts("The name of the course:");
puts(p_stu_cou->cour->course_nam);
p_stu_cou->pss=k_stu;
puts("The name of the student:");
puts(p_stu_cou->pss->stu_nam);
p_stu_cou->psc=NULL;
getchar();
if(k_stu->stu_pc==NULL)
k_stu->stu_pc=p_stu_cou;
else
{
p_stu_cou->psc=k_stu->stu_pc;
k_stu->stu_pc=p_stu_cou;
}
create_stu_cou(&head_stu_cou,p_stu_cou);
puts("Ok!");
return (1);
}
int test_course (void)
{
char cc_stu_number[LENGTH_STU_NUMBER];
struct student * k_stu;
struct stu_course *k_stu_cou;
puts("input the number of student you want to know:");
gets(cc_stu_number);
k_stu=head_stu;
while(k_stu)
{
if(strcmp(cc_stu_number,k_stu->stu_number)==0)
{
puts("the student:");
puts(k_stu->stu_nam);
getchar();
break;
}
k_stu=k_stu->stu_ps;
}
if(k_stu==NULL)
{
puts("No student!");
return (0);
}
else
{
puts("the course of the student:");
k_stu_cou=k_stu->stu_pc;
while(k_stu_cou)
{
puts(" Name:");
puts(k_stu_cou->cour->course_nam);
puts(" Number:");
puts(k_stu_cou->cour->course_number);
puts(" Date:");
puts(k_stu_cou->cour->course_date);
getchar();
k_stu_cou=k_stu_cou->psc;
}
}
return (1);
}
int choose_course_yuanxi (struct stu_course *p_stu_cou)
{
char cc_yua_name[LENGTH_YUANXI_NAME];
char cc_cou_number[LENGTH_COURSE_NUMBER];
struct yuanxi* k_yua;
struct course* k_cou;
struct major* k_maj;
struct class* k_cla;
struct student* k_stu;
puts("input the name of the yuanxi:"); /* this place may change to number or others */
gets(cc_yua_name);
puts("input the number of the course:");
gets(cc_cou_number);
k_yua=head_yua;
while(k_yua)
{
if(strcmp(cc_yua_name,k_yua->yuanxi_nam)==0)
{
puts("the yuanxi:");
puts(k_yua->yuanxi_nam);
break;
}
k_yua=k_yua->yuanxi_py;
}
if(k_yua==NULL)
{
puts("the yuanxi is not existed.");
getchar();
return(0);
}
k_cou=head_cou;
while(k_cou)
{
if(strcmp(cc_cou_number,k_cou->course_number)==0)
{
puts("the course:");
puts(k_cou->course_nam);
getchar();
break;
}
if(k_cou==NULL)
{
puts("the course is not existed.");
getchar();
return(0);
}
k_cou=k_cou->course_pc;
}
k_maj=k_yua->yuanxi_pm;
while(k_maj)
{
k_cla=k_maj->major_pc;
while(k_cla)
{
k_stu=k_cla->class_ps;
while(k_stu)
{
p_stu_cou=(struct stu_course *)malloc(sizeof(struct stu_course));
strcpy(p_stu_cou->stu_course_number,k_cou->course_number);
strcpy(p_stu_cou->stu_course_number,k_stu->stu_number);
p_stu_cou->cour=k_cou;
p_stu_cou->pss=k_stu;
p_stu_cou->psc=NULL;
p_stu_cou->stu_course_psc=NULL;
if(k_stu->stu_pc==NULL)
k_stu->stu_pc=p_stu_cou;
else
{
p_stu_cou->psc=k_stu->stu_pc;
k_stu->stu_pc=p_stu_cou;
}
puts("Finish:");
puts(k_stu->stu_nam);
create_stu_cou(&head_stu_cou,p_stu_cou);
getchar();
k_stu=k_stu->stu_class_ps;
p_stu_cou=NULL;
}
puts("Finish the class.");
printf("%s %s/n",k_cla->class_major,k_cla->class_num);
k_cla=k_cla->major_pc;
}
puts("Finish the major.");
puts(k_maj->major_nam);
k_maj=k_maj->major_yuanxi_pm;
}
}
int choose_course_major (struct stu_course *p_stu_cou)
{
char cc_maj_name[LENGTH_MAJOR_NAM];
char cc_cou_number[LENGTH_COURSE_NUMBER];
struct major *k_maj;
struct course *k_cou;
struct class *k_cla;
struct student *k_stu;
puts("input the name of the major:");
gets(cc_maj_name);
puts("input the number of the course:");
gets(cc_cou_number);
k_maj=head_maj;
while(k_maj)
{
if(strcmp(cc_maj_name,k_maj->major_nam)==0)
{
puts("the major:");
puts(k_maj->major_nam);
getchar();
break;
}
k_maj=k_maj->pm;
}
if(k_maj==NULL)
{
puts("the major is not existed.");
getchar();
return (0);
}
k_cou=head_cou;
while(k_cou)
{
if(strcmp(cc_cou_number,k_cou->course_number)==0)
{
puts("the course:");
puts(k_cou->course_nam);
getchar();
break;
}
k_cou=k_cou->course_pc;
}
if(k_cou==NULL)
{
puts("the course is not existed.");
getchar();
return (0);
}
k_cla=k_maj->major_pc;
while(k_cla)
{
k_stu=k_cla->class_ps;
while(k_stu)
{
p_stu_cou=(struct stu_course *)malloc(sizeof(struct stu_course));
strcpy(p_stu_cou->stu_course_number,cc_cou_number);
strcpy(p_stu_cou->stu_course_stu_number,k_stu->stu_number);
p_stu_cou->cour=k_cou;
p_stu_cou->pss=k_stu;
p_stu_cou->psc=NULL;
p_stu_cou->stu_course_psc=NULL;
if(k_stu->stu_pc==NULL)
k_stu->stu_pc=p_stu_cou;
else
{
p_stu_cou->psc=k_stu->stu_pc;
k_stu->stu_pc=p_stu_cou;
}
puts("Finish:");
puts(k_stu->stu_nam);
create_stu_cou(&head_stu_cou,p_stu_cou);
getchar();
k_stu=k_stu->stu_class_ps;
p_stu_cou=NULL;
}
puts("Finish the class.");
printf("%s %s/n",k_cla->class_major,k_cla->class_num);
k_cla=k_cla->major_pc;
}
}
void create_stu_cou (struct stu_course **head_stu_cou,struct stu_course *p_stu_cou)
{
p_stu_cou->mark=-1;
if(*head_stu_cou==NULL)
*head_stu_cou=p_stu_cou;
else
{
p_stu_cou->stu_course_psc=*head_stu_cou;
*head_stu_cou=p_stu_cou;
}
}
/********* write mark *****************/
int write_mark (struct stu_course *head_stu_cou)
{
int tag=0;
char cc_cou_number[LENGTH_COURSE_NUMBER];
struct stu_course *k_stu_cou;
puts("input the number of the course:");
gets(cc_cou_number);
k_stu_cou=head_stu_cou;
while(k_stu_cou)
{
if(strcmp(cc_cou_number,k_stu_cou->stu_course_number)==0)
{
if(k_stu_cou->mark==-1)
puts("the mark is written first.");
printf("%s/t%s/t",cc_cou_number,k_stu_cou->pss->stu_nam);
scanf("%d",&(k_stu_cou->mark));
getchar();
tag=1;
}
k_stu_cou=k_stu_cou->stu_course_psc;
}
if(tag==0)
{
puts("the course is not existed or nobody choose the course.");
getchar();
return (0);
}
else
{
puts("the work is over.");
getchar ();
return (1);
}
}
int check_mark (struct student *head_stu)
{
int tag=0;
char cc_stu_number[LENGTH_STU_NUMBER];
struct student *k_stu;
struct stu_course *k_stu_cou;
puts("input the number of the student:");
gets(cc_stu_number);
k_stu=head_stu;
while(k_stu)
{
if(strcmp(cc_stu_number,k_stu->stu_number)==0)
{
k_stu_cou=k_stu->stu_pc;
if(k_stu_cou==NULL)
{
puts("the student havn't chosed any course.");
getchar();
return (0);
}
else
{
printf("%s/t%s/n",k_stu->stu_number,k_stu->stu_nam);
while(k_stu_cou)
{
if(k_stu_cou->mark==-1)
{
printf("%s %s",k_stu_cou->stu_course_number,k_stu_cou->cour->course_nam);
printf(" %s/n","No mark");
}
else
{
printf("%s %s %d/n",k_stu_cou->stu_course_number,k_stu_cou->cour->course_nam,k_stu_cou->mark);
}
k_stu_cou=k_stu_cou->psc;
}
puts("-------------------------------------------");
getchar();
return (1);
}
}
tag=1;
k_stu=k_stu->stu_ps;
}
if(tag==0)
{
puts("the student is not existed'");
getchar();
return (0);
}
}
相关文章推荐
- My Oracle Support Metalink站点最近将放弃flash界面转而使用ADF HTML
- 20171215Link
- 使用J-link在ADS下调试S3C6410裸机程序
- linkHashMap转实体对象
- cocos2d-x游戏实例(28)-简易动作游戏(6)
- 使用命令构建app,由于link检查中断编译过程
- 使用tp-link禁止下载
- 20171219Link
- opencv2.1移植arm 出现找不到libcv.so not found (try using -rpath or -rpath-link) 及大量 undefined reference的解决
- 20171220Link2
- 获取Gridview的HyperLinkField
- 剑指offer 编程题(28):最小的K个数
- Sensor Demo's link error under ZStack-CC2530-2.4.0-1.4.0
- 零元学Expression Blend 4 - Chapter 28 ListBox的基本运用与更改预设样式
- 【DFS】【Rqnoj28】[Stupid]愚蠢的宠物
- 20171224Link
- LINK1104:File not found
- [Luogu 3690]【模板】Link Cut Tree (动态树)
- STL容器[28]交集、并集、差集
- 12/28 图论搜索测试总结