📄 教务管理.txt
字号:
break;
}
if(key0==27) /* esc key */
{
window(1,1,80,2);
puttext(4+dx,2,19+dx,5,buf);
textbackground(WHITE);
textcolor(BLACK);
gotoxy(38,1);
cprintf("%s",chp[4]);
window(1,2,80,22);
textbackground(LIGHTGREEN);
textcolor(YELLOW);
clrscr();
}
}
if(key==20) /*print alt+t*/
{ dx=43;
i=5;
x=4+dx;
screen(x,dx,i,tongji);
if(key1==45) exit(0);
if(key!=20) goto inx;
if(key0==13)
switch(test)
{
case 1:A=1;
cprintf("\n Input the class number:");
scanf("%u",&no);
cprintf("\n Input the subject number:");
scanf("%u",&subnum);
SUBAVE(head,no,subnum,A);
break;
case 2:Above=59;Below=0;
out(head,Above,Below);
break;
case 3:
incredit(head);
break;
case 4:
Above=100;Below=0;
out(head,Above,Below);
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(47,1);
cprintf("%s",chp[5]);
window(1,2,80,22);
textbackground(LIGHTGREEN);
textcolor(YELLOW);
clrscr();
}
}
if(key==24) /*print alt+o*/
{
dx=59;
i=7;
x=4+dx;
screen(x,dx,i,outby); /*画采单窗口*/
if(key1==45) exit(0);
if(key!=24) goto inx;
if(key0==13)
switch(test)
{
case 1:
Above=100;
Below=90;
out(head, Above, Below);
break;
case 2:
Above=89;
Below=80;
out(head,Above,Below);
break;
case 3:
Above=79;
Below=70;
out(head,Above,Below);
break;
case 4:
Above=69;
Below=60;
out(head,Above,Below);
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(65,1);
cprintf("%s",chp[7]);
window(1,2,80,22);
textbackground(LIGHTGREEN);
textcolor(YELLOW);
clrscr();
}
}
if(key==35) /*print alt+h*/
{ dx=52;
i=6;
x=4+dx;
screen(x,dx,i,help);
if(key1==45) exit(0);
if(key!=35) goto inx;
if(key0==13)
switch(test)
{
case 1:
introduce();
break;
case 2:
method();
break;
case 3:
sort(head);
break;
case 4:
CLAAVE(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(56,1);
cprintf("%s",chp[6]);
window(1,2,80,22);
textbackground(LIGHTGREEN);
textcolor(YELLOW);
clrscr();
}
}
}
}
struct CLASS * create(struct CLASS *headp) /*创建文件*/
{
struct CLASS *p1;
unsigned sum;
char ch;
unsigned CREDIT;
char CH[8];
int total=0;
do{
p1=(struct CLASS *)malloc(sizeof(struct CLASS));
cprintf("\n Input class number :");
scanf("%u",&p1->no);
cprintf("\n Input administer key words :");/*创建班级管理员密码*/
scanf("%s",p1->ADMkey);
p1->next=headp->next;
headp->next=p1;
p1->first=NULL; /*创建班级链*/
p1->students=0;
do{
struct STUD *p2;
sum=0;
CREDIT=0;
p2=(struct STUD*)malloc(sizeof(struct STUD));
inx: cprintf("\n Input student's number:");
scanf("%ld",&p2->number);
if(((p2->number/100)%100)!=p1->no) /*学号要与班号统一*/
{
cprintf("Wrong number!");
goto inx;
}
cprintf(" \tInput student's name :"); /*录入学生基本信息*/
scanf("%s",p2->name);
iny: cprintf(" \tInput student's kind ('Party''League''pioneer''None'):");
scanf("%s",CH);
if(!strcmp(CH,"Party")||!strcmp(CH,"League")||!strcmp(CH,"Pioneer")||!strcmp(CH, "None "))
strcpy(p2->kind,CH);
else {cprintf("Wrong kind!");goto iny;}
cprintf(" \tInput student's keywords :");
scanf("%s",p2->STUkey);
inz:cprintf(" \tInput student's sex :");
scanf("%s",CH);
if(!strcmp(CH,"Male")||!strcmp(CH,"Female"))
strcpy(p2->sex,CH);
else {cprintf("Input wrong information!");goto inz;}
cprintf(" \tInput student's birth place :");
scanf("%s",p2->bir_p);
cprintf(" \tInput student's address :");
scanf("%s",p2->add);
cprintf(" \tInput student's age :");
scanf("%u",&p2->age);
cprintf(" \tInput student's telephone number :");
scanf("%ld",&p2->tel);
cprintf(" \tInput student's mobilephone number or input 'xxxx':");
scanf("%s",p2->mobilephone);
p2->next=p1->first;
p1->first=p2; /*创建学生链*/
p2->first=NULL;
p2->subjects=0;
do{
struct SUB *p3;
p3=(struct SUB*)malloc(sizeof(struct SUB));/*录入课程基本信息*/
cprintf("\n Input subject number:");
scanf("%u",&p3->number);
cprintf("\n Input subject name:");
scanf("%s",p3->name);
cprintf("\n Input subject credit:");
scanf("%u",&p3->credit);
cprintf(" \tInput ps_score,tx_score,un_score:");
inA: scanf("%u%u%u",&p3->ps_score,&p3->tx_score,&p3->un_score);
if(p3->ps_score>100||p3->tx_score>100||p3->un_score>100)
{ cprintf("\ninput scores small than 100");goto inA;}
sum+=p3->credit*p3->un_score;
CREDIT+=p3->credit;
p3->next=p2->first; /*创建课程链*/
p2->first=p3;
p2->subjects++;
cprintf("\n continue input subject?(y\\n)");
while(isspace(ch=getchar()));
}while(ch=='y'||ch=='Y');
p2->average=(float)sum/ CREDIT;
p1->students++;
cprintf("\n continue input student?(y\\n)");
while(isspace(ch=getchar()));
}while(ch=='y'||ch=='Y');
total++;
cprintf("\n continue input class?(y\\n)");
while(isspace(ch=getchar()));
}while(ch=='y'||ch=='Y');
p1->classes=total;
clrscr( );
SUCESSES();
return(headp);
}
void by_name(struct CLASS *headp)/*用名字查询*/
{
char CH;
char name[20];
int found=1,i=0,NUM=0,k;
struct CLASS *p1;
struct STUD *p2;
struct student
{
long number;
int age;
char name[N];
char kind[M];
char sex[M];
char bir_p[N];
char mobilephone[15];
char add[N];
long tel;
struct student* next;
};
struct student *pstud=NULL,*s2,*c2;
cprintf("Input student's name:");
scanf("%s",name);
for(p1=headp->next;p1!=NULL;p1=p1->next) /*循环查找各个班级*/
for(p2=p1->first;p2!=NULL;p2=p2->next)
{ if(!strcmp(p2->name,name))
{ s2=(struct student*)malloc(sizeof(struct student));
strcpy(s2->name,p2->name);
strcpy(s2->sex,p2->sex);
strcpy(s2->bir_p,p2->bir_p); /*创建临时链表存储匹配的信息以便控制输出*/
strcpy(s2->kind,p2->kind);
strcpy(s2->add,p2->add);
strcpy(s2->mobilephone,p2->mobilephone);
s2->tel=p2->tel;
s2->number=p2->number;
s2->age=p2->age;
s2->next=pstud;
pstud=s2;
found=0;
i++;
}
continue;
}
inf: c2=pstud;NUM=0; /*输出所有同名的学生基本信息*/
inx:
for(k=NUM;k<4+NUM&&c2!=NULL;k++,c2=c2->next) /*格式控制*/
{
cprintf("|\t number:%-22ld|\t name:%-22s|\t sex:%-10s|",c2->number,c2->name,c2->sex,c2->kind);
cprintf("|------------------------------------------------------------------------------|");
cprintf("|\t bir_p:%-23s|\t add:%-23s|\t age:%-10u|",c2->bir_p,c2->add,c2->age);
cprintf("|------------------------------------------------------------------------------|");
cprintf("|\t mobilephone:%-17s|\t tel:%-23ld|\t kind:%-9s|",c2->mobilephone,c2->tel,c2->sex);
cprintf("|------------------------------------------------------------------------------|");
}
/*翻页功能*/
inz: while(bioskey(1)==0);
key=bioskey(0);
key=key&0xff?0:key>>8;
if(key==81){ /*按PAGEDOWN*/
NUM+=5;
if(k<i) goto inx;
else {
cprintf("\t That's all!Reread,pageup! ");
goto inz;
}
}
if(key==73) /*按PAGEGEUP*/
{
NUM-=5;
if(k-5>0)goto inf;
else{
cprintf("\t For more information,pagedown! ");
goto inz;
}
}
for(c2=pstud;c2!=NULL;c2=c2->next)free(c2);
if(found) WarnSTU(); /*没有找到学生*/
}
void by_number(struct CLASS *headp) /*用学号查询*/
{
int found=1;
long number;
struct STUD *p2;
struct CLASS *p1;
cprintf("Input student's number:");
scanf("%ld",&number);
for(p1=headp->next;p1!=NULL;p1=p1->next){
for(p2=p1->first;p2->number!=number&&p2!=NULL;p2=p2->next) /*格式控制*/
;
if(p2){cprintf("|\t number:%-22ld|\t name:%-22s|\t sex:%-10s|",p2->number,p2->name,p2->sex,p2->kind);
cprintf("|------------------------------------------------------------------------------|");
cprintf("|\t bir_p:%-23s|\t add:%-23s|\t age:%-10u|",p2->bir_p,p2->add,p2->age);
cprintf("|------------------------------------------------------------------------------|");
cprintf("|\t mobilephone:%-17s|\t tel:%-23ld|\t kind:%-9s|",p2->mobilephone,p2->tel,p2->sex);
cprintf("|------------------------------------------------------------------------------|");
found=0;
p2=NULL;
}
}
if(found) WarnSTU();
}
void by_tel(struct CLASS *headp) /*用电话号码查询*/
{
int found=1;
struct STUD *p2;
struct CLASS *p1;
long tel;
cprintf("\nInput the student's tel:");
scanf("%ld",&tel);
for(p1=headp->next;p1!=NULL;p1=p1->next)
for(p2=p1->first;p2!=NULL;p2=p2->next)
{ if(p2->tel==tel){ /*格式控制*/
cprintf("|\t number:%-22ld|\t name:%-22s|\t sex:%-10s|",p2->number,p2->name,p2->sex,p2->kind);
cprintf("|------------------------------------------------------------------------------|");
cprintf("|\t bir_p:%-23s|\t add:%-23s|\t age:%-10u|",p2->bir_p,p2->add,p2->age);
cprintf("|------------------------------------------------------------------------------|");
cprintf("|\t mobilephone:%-17s|\t tel:%-23ld|\t kind:%-9s|",p2->mobilephone,p2->tel,p2->sex);
cprintf("|------------------------------------------------------------------------------|");
found=0;
}
continue;
}
if(found)
WarnSTU(); /*没有找到学生*/
}
void by_age(struct CLASS *headp) /*按年龄查询,输出所有同年龄的学生基本信息*/
{
char CH;
unsigned age1;
int found=1,i=0,NUM=0,k;
struct CLASS *p1;
struct STUD *p2;
char student[30][6][30];
long num[30][2];
unsigned age[30][1];
cprintf("Input student's age:");
scanf("%d",&age1);
for(p1=headp->next;p1!=NULL;p1=p1->next)
for(p2=p1->first;p2!=NULL;p2=p2->next)
{ if(p2->age==age1)
{
strcpy(student[i][0],p2->name); /*将所有匹配信息存入数组以便控制输出*/
strcpy(student[i][1],p2->sex);
strcpy(student[i][2],p2->bir_p);
strcpy(student[i][3],p2->kind);
strcpy(student[i][4],p2->add);
strcpy(student[i][5],p2->mobilephone);
num[i][0]=p2->tel;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -