?? stumanager.c
字號(hào):
void Display(int cla,int p)
{
int x1=90,x2=505,y1=90,y2=390;
int i=0,n,t=0,j;
int k;
int stx1=105,stx2=200,stx3=255,stx4=305,stx5=360,stx6=415,stx7=465;
int sty=140;
int math=0,eng=0,c=0,cpp=0,java=0;
char score[5][4];
char name[11]="";
char pope[4]="";
char now[5]="";
char all[3]="";
FILE*fp;
fp=fopen("Info.txt","r");
for(i=0;i<cla-1;i++)
{
fscanf(fp,"%s%d",name,&n);
for(j=0;j<n;j++)
fscanf(fp,"%s%s%d%d%d%d%d",name,pope,&math,&eng,&c,&cpp,&java);
}
fscanf(fp,"%s%d",name,&n);
t=n/16;
if(n%16!=0) t++;
if(p>t||p<1) {fclose(fp); return ; }
setfillstyle(1,15);
bar(x1+12,y1+42,x2-12,y2-7);
setcolor(7);
line(x1+25+10*8,y1+42,x1+25+10*8,y2-7);
line(x1+25+10*8+50,y1+42,x1+25+10*8+50,y2-7);
for(i=1;i<5;i++)
line(245+i*52,y1+42,245+i*52,y2-7);
sprintf(all,"%d",t);
sprintf(now,"%d",p);strcat(now,"/");
setfillstyle(1,10);
bar(355,100,380,110);
setcolor(7);
outtextxy(360,100,now);
outtextxy(375,100,all);
for(i=0;i<(p-1)*16;i++)
fscanf(fp,"%s%s%d%d%d%d%d",name,pope,&math,&eng,&c,&cpp,&java);
if(p*16>n) k=n;
else k=p*16;
for(i=(p-1)*16;i<k;i++)
{
fscanf(fp,"%s%s%d%d%d%d%d",name,pope,&math,&eng,&c,&cpp,&java);
sprintf(score[0],"%d",math);
sprintf(score[1],"%d",eng);
sprintf(score[2],"%d",c);
sprintf(score[3],"%d",cpp);
sprintf(score[4],"%d",java);
setcolor(RED);
outtextxy(stx1,sty+(i%16)*15,name);
outtextxy(stx2,sty+(i%16)*15,pope);
outtextxy(stx3,sty+(i%16)*15,score[0]);
outtextxy(stx4,sty+(i%16)*15,score[1]);
outtextxy(stx5,sty+(i%16)*15,score[2]);
outtextxy(stx6,sty+(i%16)*15,score[3]);
outtextxy(stx7,sty+(i%16)*15,score[4]);
delay(8000);
}
fclose(fp);
return ;
}
void Input(char name[],int accept)
{
FILE*fp;
int n=0;
int i=0,j=0;
int yes=0;
char name1[11]="";
char pope[4]="";
char temp[11]="";
if(accept==1)
{
setfillstyle(1,3);
bar(230,160,380,220);
setcolor(7);
outtextxy(285,180,"ERROR!");
outtextxy(230,200,"You have no rights!");
getch();
setfillstyle(1,7);
bar(230,160,380,220);
return;
}
else if(accept==2)
{
fp=fopen("stu.txt","r");
for(j=1;j<=3;j++)
{
fscanf(fp,"%s%d",name1,&n);
for(i=0;i<n;i++)
{
fscanf(fp,"%s%s%s",name1,temp,pope);
if(strcmp(name1,name)==0)
{
yes=1;break;
}
}if(yes==1)break;
}
InputClass(j,accept);
}
else if(accept==3)
{
OperateInput(accept);
}
return;
}
void InputClass(int cla,int accept)
{
int p=1;
int i=0;
int t=0;
int key=0;
int a=0;
int s=0;
t=getnumber(cla);
a=t/16;
if(t%16!=0) a++;
DrawInput();
DisplayInput(cla,p,i);
while(1)
{
if(p==a)
s=t%16-1;
else s=15;
key=bioskey(0);
switch(key)
{
case Down:
if(i>=0&&i<s)
{
i++;
DisplayInput(cla,p,i);
}
case Up:
if(i<=15&&i>0)
{
i--;
DisplayInput(cla,p,i);
}
break;
case Right:
{
if(p<a)
{
p++;i=0;DisplayInput(cla,p,i);
}
} break;
case Left:
{
if(p>1)
{
p--;i=0;DisplayInput(cla,p,i);
}
}
break;
case Enter:test(cla,p,i,accept);DisplayInput(cla,p,i);break; /*此處為輸入數(shù)據(jù)函數(shù)*/
case Esc:setfillstyle(1,7);bar(80,90,515,400);return;
default:break;
}
}return;
}
void DrawInput () /*畫圖*/
{
int i=0;
int x1=90,x2=505,y1=90,y2=390;
setfillstyle(1,11);
bar(x1,y1,x2,y1+20);
bar(x1,y1+20,x1+10,y2);
bar(x2-10,y1+20,x2,y2);
bar(x1+10,y2-5,x2-10,y2);
setcolor(6);
outtextxy(x1+30,y1+25,"Name");
outtextxy(x1+25+10*8+10,y1+25,"Iden") ;
outtextxy(260,y1+25,"Math");
outtextxy(312,y1+25,"Eng");
outtextxy(364,y1+25,"C");
outtextxy(416,y1+25,"C++");
outtextxy(458,y1+25,"Java");
setfillstyle(1,15);
bar(x1+12,y1+42,x2-12,y2-7);
setcolor(7);
line(x1+25+10*8,y1+42,x1+25+10*8,y2-7);
line(x1+25+10*8+50,y1+42,x1+25+10*8+50,y2-7);
for(i=1;i<5;i++)
line(245+i*52,y1+42,245+i*52,y2-7);
setcolor(7);
outtextxy(430,100," < >");
return;
}
void DisplayInput(int cla,int p,int d) /*未顯示班級(jí)名*/
{
char name[11]="";
char pope[4]="";
char score[5][4];
char now[5]="";
char all[3]="";
int i=0,n=0,t=0;
int k=0;
int j=0;
int stx1=105,stx2=200,stx3=255,stx4=305,stx5=360,stx6=415,stx7=465;
int sty=140;
int x1=90,x2=505,y1=90,y2=390;
FILE*fp;
int math=0,eng=0,c=0,cpp=0,java=0;
if(cla==1)
strcpy(name,"Class1");
else if(cla==2)
strcpy(name,"Class2");
else if(cla==3)
strcpy(name,"Class3");
setcolor(4);
outtextxy(280,95,name);
fp=fopen("Info.txt","r");
for(i=0;i<cla-1;i++)
{
fscanf(fp,"%s%d",name,&n);
for(j=0;j<n;j++)
fscanf(fp,"%s%s%d%d%d%d%d",name,pope,&math,&eng,&c,&cpp,&java);
}
fscanf(fp,"%s%d",name,&n);
t=n/16;
if(n%16!=0) t++;
if(p>t||p<1) {fclose(fp); return ; }
setfillstyle(1,15);
bar(x1+12,y1+42,x2-12,y2-7);
setcolor(7);
line(x1+25+10*8,y1+42,x1+25+10*8,y2-7);
line(x1+25+10*8+50,y1+42,x1+25+10*8+50,y2-7);
for(i=1;i<5;i++)
line(245+i*52,y1+42,245+i*52,y2-7);
sprintf(all,"%d",t);
sprintf(now,"%d",p);
strcat(now,"/");
setfillstyle(1,11);
bar(355,100,380,110);
setcolor(7);
outtextxy(360,100,now);
outtextxy(375,100,all);
for(i=0;i<(p-1)*16;i++)
fscanf(fp,"%s%s%d%d%d%d%d",name,pope,&math,&eng,&c,&cpp,&java);
if(p*16>n) k=n;
else k=p*16;
for(i=(p-1)*16;i<k;i++)
{
fscanf(fp,"%s%s%d%d%d%d%d",name,pope,&math,&eng,&c,&cpp,&java);
sprintf(score[0],"%d",math);
sprintf(score[1],"%d",eng);
sprintf(score[2],"%d",c);
sprintf(score[3],"%d",cpp);
sprintf(score[4],"%d",java);
if((i)%16==d)
{
setfillstyle(1,7);
bar(x1+13,sty+(i%16)*15-3,x2-14,sty+(i%16+1)*15-5);
setcolor(GREEN);
}
else setcolor(13);
outtextxy(stx1,sty+(i%16)*15,name);
outtextxy(stx2,sty+(i%16)*15,pope);
outtextxy(stx3,sty+(i%16)*15,score[0]);
outtextxy(stx4,sty+(i%16)*15,score[1]);
outtextxy(stx5,sty+(i%16)*15,score[2]);
outtextxy(stx6,sty+(i%16)*15,score[3]);
outtextxy(stx7,sty+(i%16)*15,score[4]);
}
fclose(fp);
return ;
}
int getnumber(int cla)
{
int i=0;
FILE*fp;
int n=0,j=0;
char temp[11]="";
int s;
fp=fopen("Info.txt","r");
for(i=0;i<cla-1;i++)
{
fscanf(fp,"%s%d",temp,&n);
for(j=0;j<n;j++)
fscanf(fp,"%s%s%d%d%d%d%d",temp,temp,&s,&s,&s,&s,&s);
}
fscanf(fp,"%s%d",temp,&s);
fclose(fp);
return s;
}
void OperateInput(int accept)
{
int key=0;
int i=0;
DrawInputList(0);
while(1)
{
key=bioskey(0);
switch(key)
{
case Down:
if(i>=0&&i<2)
{
i++;
DrawInputList(i);
}
break;
case Up:
if(i<=3&&i>0)
{
i--;
DrawInputList(i);
}
break;
case Esc:setfillstyle(1,7);bar(220,37,300,82);return;
case Enter:
InputClass(i+1,accept);break;
default:break ;
}
}
return;
}
void DrawInputList(int m) /*畫下拉菜單2(Member)*/
{
char Class[][7]={"Class1","Class2","Class3"};
int i=0;
setfillstyle(1,11);
bar(220,37,300,82);
setcolor(WHITE);
for(i=0;i<3;i++)
{
outtextxy(225,43+i*15,Class[i]);
}
setfillstyle(1,8);
bar(220,37+15*m,300,37+15*(m+1));
setcolor(RED);
outtextxy(225,43+m*15,Class[m]);
return;
}
/*****************************************************************/
void test(int cla,int p,int n,int accept)
{
struct Information*p1,*p2,*p3,*q,*head1,*head2,*head3;
int n1=0,n2=0,n3=0;
FILE*fp;
int i=0;
int num=0;
int key=0;
char temp[11]="";
int x1=90,x2=505;
int pop=1;
int sty=140;
int stx1=105,stx2=200,stx3=255,stx4=305,stx5=360,stx6=415,stx7=465;
char score[5][4]={""};
char right[2]="";
char ud[2]="";
int j=0;
num=(p-1)*16+n+1;
sprintf(right,"%c",16);/*讀入兩個(gè)符號(hào)*/
sprintf(ud,"%c",23);
/*************將文件讀入結(jié)構(gòu)體中********************/
fp=fopen("Info.txt","r");
fscanf(fp,"%s%d",temp,&n1);
p1=head1=(struct Information*)malloc(sizeof(struct Information));
p1->next=NULL;
for(i=0;i<n1;i++)
{
p1=p1->next=(struct Information*)malloc(sizeof(struct Information));
p1->next=NULL;
fscanf(fp,"%s%s%d%d%d%d%d",p1->name,p1->pope,&(p1->math),&(p1->english),&(p1->clanguage),&(p1->cpp),&(p1->java));
}
fscanf(fp,"%s%d",temp,&n2);
p2=head2=(struct Information*)malloc(sizeof(struct Information));
p2->next=NULL;
for(i=0;i<n2;i++)
{
p2=p2->next=(struct Information*)malloc(sizeof(struct Information));
p2->next=NULL;
fscanf(fp,"%s%s%d%d%d%d%d",p2->name,p2->pope,&(p2->math),&(p2->english),&(p2->clanguage),&(p2->cpp),&(p2->java));
}
fscanf(fp,"%s%d",temp,&n3);
p3=head3=(struct Information*)malloc(sizeof(struct Information));
p3->next=NULL;
for(i=0;i<n3;i++)
{
p3=p3->next=(struct Information*)malloc(sizeof(struct Information));
p3->next=NULL;
fscanf(fp,"%s%s%d%d%d%d%d",p3->name,p3->pope,&(p3->math),&(p3->english),&(p3->clanguage),&(p3->cpp),&(p3->java));
}
fclose(fp);
setfillstyle(1,10);
bar(x1+13,sty+(n%16)*15-5,x2-14,sty+(n%16+1)*15-3);
setfillstyle(1,15);
bar(stx2-15,sty+(n%16)*15-2,stx3-20,sty+(n%16+1)*15-6);
bar(stx3-10,sty+(n%16)*15-2,stx3+30,sty+(n%16+1)*15-6);
bar(stx4-10,sty+(n%16)*15-2,stx4+30,sty+(n%16+1)*15-6);
bar(stx5-15,sty+(n%16)*15-2,stx5+27,sty+(n%16+1)*15-6);
bar(stx6-15,sty+(n%16)*15-2,stx6+27,sty+(n%16+1)*15-6);
bar(stx7-15,sty+(n%16)*15-2,stx7+25,sty+(n%16+1)*15-6);
if(cla==1)
p1=head1;
else if(cla==2)
p1=head2;
else if(cla==3)
p1=head3;
for(i=0;i<num;i++)
{
p1=p1->next;
}
q=p1;
sprintf(score[0],"%d",p1->math);
sprintf(score[1],"%d",p1->english);
sprintf(score[2],"%d",p1->clanguage);
sprintf(score[3],"%d",p1->cpp);
sprintf(score[4],"%d",p1->java);
setcolor(3);
outtextxy(stx1,sty+(n%16)*15,p1->name);
outtextxy(stx2-10,sty+(n%16)*15,p1->pope);
outtextxy(stx3-5,sty+(n%16)*15,score[0]);
outtextxy(stx4-5,sty+(n%16)*15,score[1]);
outtextxy(stx5-10,sty+(n%16)*15,score[2]);
outtextxy(stx6-10,sty+(n%16)*15,score[3]);
outtextxy(stx7-10,sty+(n%16)*15,score[4]);
setcolor(9);
outtextxy(stx2+25,sty+(n%16)*15,right);
while(1)
{
key=bioskey(0);
switch(key)
{
case Tab:
{
if(j==0)
{
setfillstyle(1,15);
bar(stx2+25,sty+(n%16)*15-2,stx3-20,sty+(n%16+1)*15-6);
setcolor(9);
outtextxy(stx3+22,sty+(n%16)*15,ud);
j=1;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -