📄 教务管理.txt
字号:
#include <stdio.h>
#include <conio.h>
#include <ctype.h>
#include <stdlib.h>
#define MAX 10
#define N 20
#define M 10
void by_name(struct CLASS *headp);
void by_number(struct CLASS *headp);
void by_age(struct CLASS *headp);
void by_tel(struct CLASS *headp);
void write_file(struct CLASS *headp,FILE *myfile);
float SUBAVE(struct CLASS *headp,int,int,int);
void CLAAVE(struct CLASS *headp);
void incredit(struct CLASS *headp);
void sort(struct CLASS *headp);
void method(void);
void WarnCLA();
void WarnSTU();
void WarnSUB();
void SUCESSES();
void out(struct CLASS *headp,int,int);
void introduce(void);
void screen(int,int,int,char *p[]);
struct CLASS * read_file(struct CLASS *headp,FILE *myfile);
struct CLASS * create(struct CLASS *headp);
struct CLASS * mod_stu(struct CLASS *headp);
struct CLASS * mod_sbj(struct CLASS *headp);
struct CLASS * mod_score(struct CLASS *headp);
struct CLASS * mod_STUkey(struct CLASS *headp);
struct CLASS * del_sbj(struct CLASS *headp);
struct CLASS * del_stu(struct CLASS *headp);
struct CLASS * del_cla(struct CLASS *headp);
struct CLASS * ins_cla(struct CLASS *headp);
struct CLASS * ins_stu(struct CLASS *headp);
struct CLASS * ins_sbj(struct CLASS *headp);
struct STUD{ /*学生结构体*/
long number;
unsigned subjects;
unsigned age;
float average;
char STUkey[12];
char name[N];
char kind[M];
char sex[M];
char bir_p[N];
char add[N];
long tel;
char mobilephone[15];
struct STUD* next;
struct SUB* first;
};
struct CLASS{ /*班级结构体*/
unsigned no;
unsigned students;
unsigned classes;
char ADMkey[12];
float score[MAX];
float average;
struct STUD* first;
struct CLASS* next;
};
struct SUB{ /*课程结构体*/
unsigned number;
char name[N];
unsigned credit;
unsigned ps_score;
unsigned tx_score;
unsigned un_score;
struct SUB* next;
};
FILE *fp;
int key0,key1,key,test,dx,dy,y,x,i; /*外部变量说明*/
char buf[30*10*2],buf1[30*2];
char *chp[ ]= {"file", /* 菜单项目*/
"search",
"insert",
"modify",
"delete",
"tongji",
"help",
"outby",
};
char * file[]={
"create",
"open ",
"save ",
"exit ",
};
char * search[]={
"by name",
"by number",
"by tel",
"by age",
};
char * insert[]={
"student",
"subject",
"class",
"Copy",
};
char * modify[]={
"student",
"subject",
"score ",
"STUkey",
};
char * delete[]={
"student",
"subject",
"class",
"xxxxxx",
};
char * tongji[]={
"SUBAVE",
"impass",
"incredit",
"output",
};
char * help[]={
"introduct",
"method",
"sort ",
"CLAAVE",
};
char * outby[]={
"Best",
"Good",
"Middle",
"Bad ",
};
void main()
{
char c;
int Above, Below,no,subnum,A;
struct CLASS cla;
struct CLASS * head;
struct CLASS * p1;
struct STUD * p2;
struct SUB * p3;
head=NULL;
textbackground(GREEN);
clrscr( );
window(18,7,62,16);
textbackground(WHITE); /*制作欢迎界面*/
textcolor(BLACK);
clrscr( );
window(36,8,74,9);
cprintf("WELCOME!");
window(28,9,74,10);
cprintf("Teaching management system");
window(24,10,74,11);
cprintf("Copyright ZhuTao & Star Dragon Li");
window(30,11,74,12);
cprintf("Number:012003017307");
window(26,12,74,13);
cprintf("Computer Science & Technology");
window(25,13,74,14);
cprintf("Informtion Security Class four.");
window(34,14,74,15);
cprintf("Date:2004.8");
window(1,1,80,1);
textbackground(WHITE);
textcolor(BLACK);
clrscr( );
window(1,1,80,2);
for(i=0;i<8;i++)
cprintf(" %s",chp[i]);
while(1)
{
key=0;
while(bioskey(1)==0);
key=bioskey(0);
key=key&0xff?0:key>>8;
inx: if(key==45) exit(0); /* press alt+x*/
if(key==33) /* press alt+f*/
{
dx=0,i=0;
x=4+dx;
screen(x,dx,i,file);
if(key!=33) goto inx;
if(key1==45) exit(0); /* alt + x */
if(key0==13)
switch(test)
{
case 1:
head=create(head);
break;
case 2:
fp=fopen("kugua.dat","rb");
fread(&cla,sizeof(struct CLASS),1,fp); /*打开文件*/
head->next=NULL;
cla.next=NULL;
cla.first=NULL;
head->next=read_file(&cla,fp);
fclose(fp);
break;
case 3:
if((fp=fopen("kugua.dat","wb"))==NULL){
fprintf(stderr,"error:cantcreate file!\n");
return;
}
fwrite(head->next,sizeof(struct CLASS),1,fp);
write_file(head->next,fp);
fclose(fp);
break;
case 4:
window(1,2,80,20);
textbackground(LIGHTGREEN);
textcolor(YELLOW);
clrscr();
window(20,8,60,13);
textbackground(WHITE);
textcolor(BLACK);
clrscr();
window(29,10,60,11);
textbackground(WHITE);
textcolor(BLACK);
gotoxy(40,22);
cprintf("Save your change?(y/n)");
while(isspace(c=getchar()));
if(c=='y'||c=='Y'){
if((fp=fopen("kugua.dat","wb"))==NULL){
fprintf(stderr,"error:can't create file!\n");
return;
}
rewind(fp);
fwrite(head->next,sizeof(struct CLASS),1,fp);
write_file(head->next,fp);
fclose(fp);
for(p1=head->next;p1!=NULL;p1=p1->next){ /*退出时释放内存*/
for(p2=p1->first;p2!=NULL;p2=p2->next){
for(p3=p2->first;p3!=NULL;p3=p3->next)
free(p3);
free(p2);
}
free(p1);
}
}
exit(0);
default:
break;
}
if(key0==27) /* esc key */
{
window(1,1,80,2);
puttext(4+dx,2,15+dx,7,buf);
textbackground(WHITE);
textcolor(BLACK);
gotoxy(4,1);
cprintf("%s",chp[0]);
window(1,2,80,22);
textbackground(LIGHTGREEN);
textcolor(YELLOW);
clrscr();
}
}
if(key==31) /*press alt+s*/
{
dx=7;
x=4+dx;
i=1;
screen(x,dx,i,search);
if(key1==45) exit(0);
if(key!=31) goto inx;
if(key0==13)
switch(test)
{
case 1:
by_name(head);
break;
case 2:
by_number(head);
break;
case 3:
by_tel(head);
break;
case 4:
by_age(head);
break;
default:
cprintf("\nInput error!");
break;
}
if(key==27) /* esc key */
{
window(1,1,80,2);
puttext(4+dx,2,15+dx,7,buf);
textbackground(WHITE);
textcolor(BLACK);
gotoxy(11,1);
cprintf("%s",chp[1]);
window(1,2,80,22);
textbackground(LIGHTGREEN);
textcolor(YELLOW);
clrscr();
}
}
if(key==23) /* alt+i */ /*print alt+i*/
{ dx=2*8;
i=2;
x=4+dx;
screen(x,dx,i,insert);
if(key1==45) exit(0);
if(key!=23) goto inx;
if(key0==13)
switch(test)
{
case 1:
head=ins_stu(head);
break;
case 2:
head=ins_sbj(head);
break;
case 3:
head=ins_cla(head);
break;
case 4:
break;
default:
break;
}
if(key0==27) /* esc key */
{
window(1,1,80,2);
puttext(4+dx,2,15+dx,7,buf);
textbackground(WHITE);
textcolor(BLACK);
gotoxy(20,1);
cprintf("%s",chp[2]);
window(1,2,80,22);
textbackground(LIGHTGREEN);
textcolor(YELLOW);
clrscr();
}
}
if(key==50) /*alt+m*/ /*print alt+m*/
{ dx=25;
i=3;
x=4+dx;
screen(x,dx,i,modify);
if(key1==45) exit(0);
if(key!=50) goto inx;
if(key0==13)
switch(test)
{
case 1:
head=mod_stu(head);
break;
case 2:
head=mod_sbj(head);
break;
case 3:
head=mod_score(head);
break;
case 4:head=mod_STUkey(head);
break;
default:
break;
}
if(key0==27) /* esc key */
{
window(1,1,80,2);
puttext(4+dx,2,15+dx,7,buf);
textbackground(WHITE);
textcolor(BLACK);
gotoxy(29,1);
cprintf("%s",chp[3]);
window(1,2,80,22);
textbackground(LIGHTGREEN);
textcolor(YELLOW);
clrscr();
}
}
if(key==32) /* alt+d */
{ dx=34;
i=4;
x=4+dx;
screen(x,dx,i,delete);
if(key1==45) exit(0);
if(key!=32) goto inx;
if(key0==13)
switch(test)
{
case 1:
head=del_stu(head);
break;
case 2:
head=del_sbj(head);
break;
case 3:
head=del_cla(head);
break;
case 4:
break;
default:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -