大程序
- c语言结课前的最后一次作业。
- 感觉突然就结课,直到昨晚才恍然感觉,好像再也看不到这位亦师亦友的老师了。
- 必须承认的是,倘若没有这位老师,我是无法培养起如此浓厚的编程兴趣的。
挂科无疑 - 希望学弟学妹们能珍惜每一节王老师的课吧
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<dos.h>
#include<stdlib.h>
#include<bios.h>
#include<graphics.h>
void line_yxy();
void dayin_yxy();
void shuru();
void fanye();
void huatu();
void dakai();
void shub();
void cursor_yxy();
void read_yxy();
void init_yxy();
void disphz();
void yuanbing();
void start();
void finish();
void mysound();
void off_y();
#define DZ 16
#define HZ "HZK16"
#define G 4000
#define DIV 1193180
#define vi 4
#define vb 10
#define P 3.1415926
char bits,mulu[50]={0};
int N=0,page=0;
void *k;
FILE *fp;
typedef struct
{
char biao;
char time[3];
long num;
short head_num;
short record_long;
char kong[20];
}HEAD;
typedef struct
{
char name[10];
char bai;
char lei;
long begin;
char kuan;
char wei;
char kong[14];
}FIELD;
struct
{
char name[30];
int math;
int english;
int computer;
int numc;
}stu[101]={0};
struct S
{
char c;
struct S *last;
struct S *next;
};
typedef union
{
int key;
char c[2];
}U;
int main()
{
int i,x,y,x1,y1;
int gdriver=DETECT,gmode;
char name2[]={"打开失败"},name3[]={"按任意键重新输入文件名"};
initgraph(&gdriver,&gmode,"");
start();
shuru();
fp=fopen(mulu,"rb");
while(fp==NULL)
{
cleardevice();
for(i=0;name2[i];i+=2)
disphz(30+12*i,50,&name2[i],15);
for(i=0;name3[i];i+=2)
disphz(50+12*i,80,&name3[i],15);
getch();
shuru();
fp=fopen(mulu,"rb");
}
dakai();
fanye();
finish();
return 0;
}
void shuru()
{
void *j;
U p,o;
struct S *head,*d,*q,*f,*g;
int h,n=0,t,s,i;
long size;
int x=0,y=0,button,x1,y1,x2,y2,flag,a;
char name[5]={0},name1[]={".dbf"},name2[5]={0},c;
char zhi[]={"请按下回车运行程序或点击退出键退出程序"},shi[]={"输入文件名时允许不加"},fu[]={"退出"};
char sou[7]={"回车"};
for(t=0;t<50;t++)
mulu[t]=0;
cleardevice();
setcolor(15);
setfillstyle(1,15);
rectangle(0,0,639,479);
floodfill(1,1,15);
head=(struct S *)malloc(sizeof(struct S ));
(*head).c=0;
(*head).last=(*head).next=NULL;
q=head;
setfillstyle(1,0);
for(n=0;zhi[n];n+=2)
disphz(50+n*12,50,&zhi[n],0);
for(n=0;shi[n];n+=2)
disphz(50+n*12,80,&shi[n],0);
setcolor(0);
settextstyle(0,0,2);
setfillstyle(1,15);
outtextxy(280,80,name1);
rectangle(100,150,555,170);
setcolor(0);
setfillstyle(1,14);
bar3d(450,330,500,360,3,1);
bar3d(380,330,430,360,3,1);
floodfill(451,331,0);
floodfill(381,331,0);
for(n=0;fu[n];n+=2)
disphz(460+n*12,338,&fu[n],4);
for(n=0;sou[n];n+=2)
disphz(390+n*12,338,&sou[n],4);
x=x1=319,y=y1=339,button=0;
cursor_yxy(x,y);
setfillstyle(1,11);
size=imagesize(x1,y1,x1+10,y1+15);
j=malloc(size);
getimage(x1,y1,x1+10,y1+15,j);
putimage(x,y,k,0);
settextstyle(0,0,2);
n=x2=102,y2=152;
while(1)
{
read_yxy(&x,&y,&button);
if(x==x1&&y==y1&&!button)
{
if(x<630)
putimage(x,y,k,0);
}
else
{
putimage(x1,y1,j,0);
free(j);
size=imagesize(x,y,x+10,y+15);
j=malloc(size);
getimage(x,y,x+10,y+15,j);
cursor_yxy(x,y);
}
if(x<380||x>430&&x<450||x>500||y>360||y<330)
{
for(a=0;fu[a];a+=2)
disphz(460+a*12,338,&fu[a],4);
for(a=0;sou[a];a+=2)
disphz(390+a*12,338,&sou[a],4);
}
flag=0;
if(x>=450&&x<=500&&y>=330&&y<=360)
{
if(button)
{
off_y();
}
flag=1;
}
else if(x>=380&&x<=430&&y>=330&&y<=360)
{
if(button)
{
d=(*head).next;
h=0;
while(1)
{
mulu[h++]=(*d).c;
if((*d).next==NULL)
{
mulu[h]=0;
break;
}
d=(*d).next;
}
s=strlen(mulu);
for(t=s-1,h=3;h>=0;t--,h--)
name2[h]=mulu[t];
if(strcmp(name2,name1)!=0)
{
for(t=s,h=0;h<4;h++,t++)
mulu[t]=name1[h];
mulu[t]=0;
}
break;
}
flag=2;
}
if(flag)
{
if(flag==1)
{
for(a=0;fu[a];a+=2)
disphz(460+a*12,338,&fu[a],11);
}
if(flag==2)
{
for(a=0;sou[a];a+=2)
disphz(390+a*12,338,&sou[a],11);
}
}
if(x<630)
putimage(x,y,k,0);
y1=y,x1=x;
settextstyle(0,0,2);
line_yxy(&x2,y2,0,0);
for(h=1;h<=3;h++)
delay(G);
p.key=bioskey(1);
if(p.key)
bioskey(0);
if(p.c[1]==0x1c)
{
d=(*head).next;
h=0;
while(1)
{
mulu[h++]=(*d).c;
if((*d).next==NULL)
{
mulu[h]=0;
break;
}
d=(*d).next;
}
s=strlen(mulu);
for(t=s-1,h=3;h>=0;t--,h--)
name2[h]=mulu[t];
if(strcmp(name2,name1)!=0)
{
for(t=s,h=0;h<4;h++,t++)
mulu[t]=name1[h];
mulu[t]=0;
}
break;
}
if((p.c[1]==0xe&&x2>102)||(p.c[1]==0x53&&(*q).next!=NULL))
{
if(p.c[0]=='.');
else if((*q).next==NULL&&p.c[1]==0xe)
{
line_yxy(&x2,y2,15,-18);
name[0]=(*q).c;
outtextxy(x2,y2,name);
q=(*q).last;
d=(*q).next;
free(d);
(*q).next=NULL;
}
else if((*q).next!=NULL)
{
if(p.c[1]==0xe)
{
q=(*q).last;
line_yxy(&x2,y2,15,-18);
dayin_yxy(x2,y2,(*q).next);
f=(*q).next;
d=(*f).next;
(*q).next=d;
(*d).last=q;
free(f);
setcolor(0);
dayin_yxy(x2,y2,(*q).next);
}
else
{
setcolor(15);
dayin_yxy(x2,y2,(*q).next);
if((*(*q).next).next==NULL)
{
d=(*q).next;
free(d);
(*q).next=NULL;
}
else
{
f=(*q).next;
d=(*f).next;
(*q).next=d;
(*d).last=q;
free(f);
setcolor(0);
dayin_yxy(x2,y2,(*q).next);
}
}
}
if((p.c[1]==0xe&&x2>=102||p.c[1]==0x53&&(*((*q).last)).next!=NULL)&&p.c[0]!='.')
n-=18;
}
name[0]=p.c[0];
if(isalnum(name[0])||name[0]==95||name[0]==58||name[0]==92||name[0]==46);
else
name[0]=0;
if(strlen(name)&&n<548)
{
if((*q).next==NULL)
{
line_yxy(&x2,y2,15,18);
setcolor(0);
outtextxy(x2-18,y2,name);
d=(struct S *)malloc(sizeof(struct S ));
(*d).c=name[0];
(*d).next=NULL;
(*d).last=q;
(*q).next=d;
q=d;
}
else
{
c=name[0];
line_yxy(&x2,y2,15,18);
dayin_yxy(x2-18,y2,(*q).next);
setcolor(0);
d=(struct S *)malloc(sizeof(struct S));
f=(*q).next;
(*q).next=d;
(*d).last=q;
(*d).next=f;
(*f).last=d;
(*d).c=c;
dayin_yxy(x2-18,y2,(*q).next);
q=(*q).next;
}
n+=18;
}
if(p.c[1]==0x4d&&x2<n&&name[0]!=54)
{
q=(*q).next;
line_yxy(&x2,y2,15,18);
}
else if(p.c[1]==0x4b&&x2>102&&(*q).last!=NULL&&name[0]!=52)
{
q=(*q).last;
line_yxy(&x2,y2,15,-18);
}
line_yxy(&x2,y2,15,0);
for(h=1;h<=3;h++)
delay(G);
}
}
void off_y()
{
cleardevice();
closegraph();
exit(0);
}
void finish()
{
U w;
int r,times;
double a;
int freq[]={0,262,294,330,349,392,440,494};
int song[]={-6,3,3,-6,9,1,-6,-6,1,-6,1,-6,1,2,3,3,-6,3,3,-6,-6,
9,1,-6,-6,1,-6,-6,2,1,-6,0,3,5,3,5,3,3,6,6,5,-6,
0,5,3,5,3,3,3,6,6,5,10,0,3,5,3,5,3,6,6,5,-6,
0,-6,-6,-6,2,2,1,-6,3,3,-6,9,1,-6,-6,1,-6,1,-6,
1,2,3,3,-6,3,3,-6,-6,9,1,-6,-6,1,-6,-6,2,1,-6,
0,3,5,3,5,3,6,5,5,-6,0,3,5,3,5,3,6,6,5,10,
0,3,5,3,5,3,6,5,5,-6,0,-6,-6,-6,6,5,3,
0,3,5,3,5,3,6,6,5,-6,0,3,5,3,5,3,3,6,5,10,
0,3,5,3,5,3,3,6,6,5,-6,0,-6,-6,-6,9,8,1,-6,-6,
-6,3,3,3,-6,-6,9,1,-6,-6,1,-6,1,-6,1,2,3,3,-6,3,3,3,-6,-6,9,1,-6,-6,1,-6,2,1,-6
};
float div[]={4,4,4,4,4,4,4.5,4,4,4,4,4,4,8,8,2,4,4,4,8,8,
4,4,4.5,8,4,8,8,4,4,1,8,8,8,8,4,8,8,8,8,4,2,
4,8,8,4,8,8,8,8,8,4,2,8,8,8,8,4,4,8,16,4,2,
8,8,8,8,8.5,16,4,1,4,4,4,4,4,4,4.5,4,4,4,4,4,
4,8,8,2,4,4,4,8,8,4,4,4,8,4,8,8,4,4,1,
8,8,8,8,4,4,4,8,8,2,8,8,8,8,4,4,8,16,4,2,
8,8,8,8,4,4,4,8,16,2,8,8,8,8,4,4,1,
8,8,8,8,4,4,8,16,4,2,8,8,8,8,4,8,8,4,4,2,
8,8,8,8,4,8,8,8,16,4,2,8,8,8,8,4,8,16,4,1,
4,8.5,16,4,4,4,4,4,4.5,8,4,4,4,4,4,4,4,4.5,4,8.5,16,4,8,8,4,4,4.5,8,4,4,4,4,1
};
char n1[25]={"计算机科学与技术专业"},n2[11]={"2020214131"},n3[8]={"杨新艺"};
char m1[100]={"本程序为杨新艺排除万难后,呕心沥血之作,深知尚有不足,恭请斧正。"};
char c1[35]={"您可以通过点击输入键返回输入界面"},c2[30]={"支持点击声音键打开或关闭声音"};
char b1[7]={"声音"},b2[7]={"退出"},t[5]={"(E)"},s[5]={"(V)"};
int i,flag,f,d,m=0,v=0,V=1,ju=0;
int x=0,y=0,x1,y1,button,size,y3=345,y4=390;
void *j,*g,*h;
cleardevice();
setcolor(15);
setfillstyle(1,15);
rectangle(0,0,639,479);
floodfill(10,10,15);
size=imagesize(0,y3,639,y4);
g=malloc(size);
getimage(0,y3,639,y4,g);
for(i=0;m1[i]&&i<35;i+=2)
disphz(150+i*12,350,&m1[i],0);
for(f=0;m1[i];i+=2,f+=2)
disphz(50+f*12,370,&m1[i],0);
size=imagesize(x,y3,639,y4);
h=malloc(size);
getimage(0,y3,639,y4,h);
putimage(0,y3,g,0);
cleardevice();
setcolor(15);
setfillstyle(1,15);
rectangle(0,0,639,479);
floodfill(10,10,15);
setcolor(0);
for(i=0;c1[i];i+=2)
disphz(130+i*12,20,&c1[i],0);
for(i=0;c2[i];i+=2)
disphz(170+i*12,40,&c2[i],0);
setcolor(0);
setfillstyle(1,14);
for(i=0;i<=1;i++)
{
bar3d(210+i*120,400,280+i*120,430,3,1);
floodfill(211+i*120,401,0);
}
setcolor(4);
for(i=0;b1[i];i+=2)
disphz(216+i*12,408,&b1[i],4);
outtextxy(257,413,s);
for(i=0;b2[i];i+=2)
disphz(336+i*12,408,&b2[i],4);
outtextxy(375,413,t);
x1=x=319,y1=y=339,button=0,f=0,r=0,v=0;
cursor_yxy(x,y);
setfillstyle(1,11);
size=imagesize(x1,y1,x1+10,y1+15);
j=malloc(size);
getimage(x1,y1,x1+10,y1+15,j);
putimage(x,y,k,0);
while(1)
{
if(V)
{
if(v==0)
{
if(song[r]==100)
r=0;
if(song[r]<0)
a=freq[abs(song[r])]/2;
else if(song[r]>7)
a=freq[song[r]%7]*2;
else
a=freq[song[r]];
if(div[r]-(int)(div[r]+0.1)>0.4)
times=16/(int)div[r]*1.51;
times=16/(int)(div[r++]+0.1);
mysound(a*1.259921);
}
else
{
if(v==vi*100*times)
outportb(0x61,bits&0xfc);
if(v==vi*110*times)
{
outportb(0x61,bits);
v=-1;
}
}
v++;
}
m++;
if(m>vb*100)
{
if(f<55)
{
putimage(0,y3-(f-1)*5,g,0);
putimage(0,y3-f*5,h,0);
f++;
m=0;
if(f==54)
ju=1;
}
}
if(ju)
{
for(i=0;n1[i];i+=2)
disphz(200+i*12,250,&n1[i],0);
setcolor(0);
settextstyle(0,0,2);
outtextxy(240,270,n2);
for(i=0;n3[i];i+=2)
disphz(275+i*12,290,&n3[i],0);
ju=0;
}
read_yxy(&x,&y,&button);
if(bioskey(1))
w.key=bioskey(0);
else w.key=0;
if(w.c[1]==0x12)
{
if(V)
{
outportb(0x61,bits&0xfc);
outportb(0x61,bits);
}
off_y();
}
else if(w.c[1]==0x2f)
{
if(V)
{
outportb(0x61,bits&0xfc);
outportb(0x61,bits);
V=0;
}
else V=1;
}
if(x==x1&&y==y1&&!button)
{
if(x<630)
putimage(x,y,k,0);
continue;
}
else
{
putimage(x1,y1,j,0);
free(j);
size=imagesize(x,y,x+10,y+15);
j=malloc(size);
getimage(x,y,x+10,y+15,j);
cursor_yxy(x,y);
}
if(button)
for(a=1;a<=3;a++)
delay(30000);
if(x<210||x>280&&x<330||x>400||y>430||y<400)
{
settextstyle(0,0,1);
setcolor(4);
for(i=0;b1[i];i+=2)
disphz(216+i*12,408,&b1[i],4);
outtextxy(257,413,s);
for(i=0;b2[i];i+=2)
disphz(336+i*12,408,&b2[i],4);
outtextxy(375,413,t);
}
flag=0;
if(x>=210&&x<=280&&y>=400&&y<=430)
{
if(button)
{
if(V)
{
outportb(0x61,bits&0xfc);
outportb(0x61,bits);
V=0;
}
else V=1;
}
flag=1;
}
else if(x>=330&&x<=400&&y>=400&&y<=430)
{
if(button)
{
if(V)
{
outportb(0x61,bits&0xfc);
outportb(0x61,bits);
}
off_y();
}
flag=2;
}
if(flag)
{
setcolor(11);
settextstyle(0,0,1);
if(flag==1)
{
for(i=0;b1[i];i+=2)
disphz(216+i*12,408,&b1[i],11);
outtextxy(257,413,s);
}
if(flag==2)
{
for(i=0;b2[i];i+=2)
disphz(336+i*12,408,&b2[i],11);
outtextxy(375,413,t);
}
}
if(x<630)
putimage(x,y,k,0);
y1=y,x1=x;
}
}
void init_yxy(int xmin,int xmax,int ymin,int ymax)
{
_AX=0;
geninterrupt(0x33);
if(_AX==0)
{
closegraph();
exit(0);
}
_AX=7;
_CX=xmin;
_DX=xmax;
geninterrupt(0x33);
_AX=ymin;
_DX=ymax;
geninterrupt(0x33);
}
void start()
{
U w;
char name[40]={"您可以点击开始按键即刻进入程序"},name1[30]={"或者点击退出按键退出"};
char xiao[5]={":)"},ku[5]={":("},jin[8]={"开始"},tui[8]={"退出"},t[5]={"(E)"},s[5]={"(S)"};
char n1[10]={"柱状图"},n2[10]={"圆饼图"},m1[5]={"1."},m2[5]={"2."};
int i,flag;
int x=0,y=0,x1,y1,button,size;
void *j;
cleardevice();
setcolor(15);
setfillstyle(1,15);
rectangle(0,0,639,479);
floodfill(10,10,15);
shub(x,y,0);
size=imagesize(x,y,x+8,y+14);
k=malloc(size);
getimage(x,y,x+8,y+14,k);
cleardevice();
setcolor(15);
setfillstyle(1,15);
rectangle(0,0,639,479);
floodfill(10,10,15);
setcolor(0);
for(i=0;name[i];i+=2)
disphz(30+i*12,50,&name[i],0);
outtextxy(385,55,xiao);
for(i=0;name1[i];i+=2)
disphz(80+i*12,70,&name1[i],0);
outtextxy(320,75,ku);
settextstyle(0,0,2);
outtextxy(247,202,m1);
outtextxy(247,242,m2);
for(i=0;n1[i];i+=2)
disphz(280+i*12,200,&n1[i],0);
for(i=0;n2[i];i+=2)
disphz(280+i*12,240,&n2[i],0);
setcolor(0);
setfillstyle(1,14);
settextstyle(0,0,1);
for(i=0;i<=1;i++)
{
bar3d(210+i*120,300,280+i*120,330,3,1);
floodfill(211+i*120,301,0);
}
setcolor(4);
for(i=0;jin[i];i+=2)
disphz(216+i*12,308,&jin[i],4);
outtextxy(257,313,s);
for(i=0;tui[i];i+=2)
disphz(336+i*12,308,&tui[i],4);
outtextxy(375,313,t);
init_yxy(0,639,0,479);
x1=x=319,y1=y=339,button=0;
cursor_yxy(x,y);
setfillstyle(1,11);
size=imagesize(x1,y1,x1+10,y1+15);
j=malloc(size);
getimage(x1,y1,x1+10,y1+15,j);
putimage(x,y,k,0);
while(1)
{
read_yxy(&x,&y,&button);
if(bioskey(1))
w.key=bioskey(0);
else w.key=0;
if(w.c[1]==0x12)
{
off_y();
}
else if(w.c[1]==0x1f)
{
break;
}
if(x==x1&&y==y1&&!button)
{
if(x<630)
putimage(x,y,k,0);
continue;
}
else
{
putimage(x1,y1,j,0);
free(j);
size=imagesize(x,y,x+10,y+15);
j=malloc(size);
getimage(x,y,x+10,y+15,j);
cursor_yxy(x,y);
}
if(x<210||x>280&&x<330||x>400||y>330||y<300)
{
settextstyle(0,0,1);
setcolor(4);
for(i=0;jin[i];i+=2)
disphz(216+i*12,308,&jin[i],4);
outtextxy(257,313,s);
for(i=0;tui[i];i+=2)
disphz(336+i*12,308,&tui[i],4);
outtextxy(375,313,t);
}
flag=0;
if(x>=210&&x<=280&&y>=300&&y<=330)
{
if(button)
{
break;
}
flag=1;
}
else if(x>=330&&x<=400&&y>=300&&y<=330)
{
if(button)
{
off_y();
}
flag=2;
}
if(flag)
{
setcolor(11);
settextstyle(0,0,1);
if(flag==1)
{
for(i=0;jin[i];i+=2)
disphz(216+i*12,308,&jin[i],11);
outtextxy(257,313,s);
}
if(flag==2)
{
for(i=0;tui[i];i+=2)
disphz(336+i*12,308,&tui[i],11);
outtextxy(375,313,t);
}
}
if(x<630)
putimage(x,y,k,0);
y1=y,x1=x;
}
}
void yuanbing()
{
int i=0,z,f=0;
int a[6]={0},p,flag,size,h;
int x,y,x1,y1,x2,y2,button;
void *j;
double s,l=0,c;
char name[7]={"圆饼图"},name1[2][5]={"(Z)","(E)"},name2[2][7]={"柱状图","退出"};
char tuli[5][7]={"0~59","60~69","70~79","80~89","90~100"};
char b[6][5]={0};
U w;
cleardevice();
setcolor(15);
setfillstyle(1,15);
rectangle(0,0,639,479);
floodfill(10,10,15);
for(i=0;name[i];i+=2)
disphz(70+i*20,50,&name[i],0);
setcolor(0);
setfillstyle(1,14);
for(z=0;z<=1;z++)
{
bar3d(210+z*120,380,290+z*120,410,3,1);
floodfill(250+z*120,390,0);
}
disphz(218,385,&name2[0][0],4);
disphz(218+15,385,&name2[0][2],4);
disphz(218+30,385,&name2[0][4],4);
for(z=0;name2[1][z];z+=2)
disphz(338+z*12,385,&name2[1][z],4);
setcolor(4);
settextstyle(0,0,1);
for(z=0;z<=1;z++)
outtextxy(263+120*z,390,name1[z]);
for(i=1;i<=N;i++)
{
if(stu[i].numc<60)
a[0]++;
else if(stu[i].numc<70)
a[1]++;
else if(stu[i].numc<80)
a[2]++;
else if(stu[i].numc<90)
a[3]++;
else a[4]++;
}
for(i=0;i<5;i++)
f+=a[i];
setcolor(0);
settextstyle(0,0,1);
rectangle(450,55,560,170);
for(i=0;i<5;i++)
{
outtextxy(460,70+20*i,tuli[i]);
rectangle(520,70+20*i,540,78+20*i);
setfillstyle(1,i+1);
floodfill(521,71+20*i,0);
}
for(i=0;i<5;i++)
{
setfillstyle(1,i+1);
s=(double)360*a[i]/f;
p=100.0*a[i]/f;
z=s;
if(s>(z+0.5))
s=z+1;
pieslice(300,250,l,s+l,70);
if(p<10)
b[i][0]=p+48,b[i][1]='%';
else if(p<100)
b[i][0]=p/10+48,b[i][1]=p%10+48,b[i][2]='%';
else b[i][0]=49,b[i][1]=48,b[i][2]=48,b[i][3]='%';
if(a[i]>0)
{
c=(l+l+s)/2;
if(c>=0&&c<90)
{
c=P*(c/180);
x=300+abs((int)70*cos(c));
y=250-abs((int)70*sin(c));
}
else if(c<180)
{
c=P*(c/180);
x=300-abs((int)70*cos(c));
y=250-abs((int)70*sin(c));
}
else if(c<270)
{
c=P*(c/180);
x=300-abs((int)70*cos(c));
y=250+abs((int)70*sin(c));
}
else if(c<360)
{
c=P*(c/180);
x=300+abs((int)70*cos(c));
y=250+abs((int)70*sin(c));
}
if(x>300)
x1=x+20;
else
x1=x-20;
if(y>250)
y1=y+20;
else
y1=y-20;
line(x,y,x1,y1);
if(x1>300)
x2=x1+5;
else x2=x1-5;
if(y1>250)
y2=y1+5;
else y2=y1-5;
outtextxy(x2,y2,b[i]);
}
l+=s;
}
x1=x=319,y1=y=339,button=0;
cursor_yxy(x,y);
setfillstyle(1,11);
size=imagesize(x1,y1,x1+10,y1+15);
j=malloc(size);
getimage(x1,y1,x1+10,y1+15,j);
putimage(x,y,k,0);
while(1)
{
read_yxy(&x,&y,&button);
if(bioskey(1))
w.key=bioskey(0);
else w.key=0;
if(w.c[1]==0x2c)
{
fanye();
}
else if(w.c[1]==0x12)
{
finish();
}
if(x==x1&&y==y1&&!button)
{
if(x<630)
putimage(x,y,k,0);
continue;
}
else
{
putimage(x1,y1,j,0);
free(j);
size=imagesize(x,y,x+10,y+15);
j=malloc(size);
getimage(x,y,x+10,y+15,j);
cursor_yxy(x,y);
}
if(x<210||x>290&&x<330||x>410||y>410||y<380)
{
setcolor(4);
settextstyle(0,0,1);
for(z=0;z<=1;z++)
outtextxy(263+120*z,390,name1[z]);
settextstyle(0,0,1);
disphz(218,385,&name2[0][0],4);
disphz(218+15,385,&name2[0][2],4);
disphz(218+30,385,&name2[0][4],4);
for(z=0;name2[1][z];z+=2)
disphz(338+z*12,385,&name2[1][z],4);
}
flag=0;
if(x>=210&&x<=290&&y>=380&&y<=410)
{
if(button)
{
fanye();
}
flag=1;
}
else if(x>=330&&x<=410&&y>=380&&y<=410)
{
if(button)
{
finish();
}
flag=2;
}
if(flag)
{
setcolor(11);
settextstyle(0,0,1);
if(flag==1)
{
disphz(218,385,&name2[0][0],11);
disphz(218+15,385,&name2[0][2],11);
disphz(218+30,385,&name2[0][4],11);
outtextxy(263,390,name1[0]);
}
if(flag==2)
{
for(z=0;name2[1][z];z+=2)
disphz(338+z*12,385,&name2[1][z],11);
outtextxy(383,390,name1[1]);
}
}
if(x<630)
putimage(x,y,k,0);
y1=y,x1=x;
}
}
void dakai()
{
HEAD head;
FIELD field[5]={0};
int i,j,k,n,flag;
int a,b,c;
char Flag,score[20]={0};
fread(&head,32,1,fp);
flag=(head.head_num-33)/32;
for(i=1;i<=flag;i++)
{
fread(&field[0],32,1,fp);
if(strcmp(field[0].name,"姓名")==0)
field[1]=field[0];
if(strcmp(field[0].name,"英语")==0)
field[2]=field[0];
if(strcmp(field[0].name,"数学")==0)
field[3]=field[0];
if(strcmp(field[0].name,"计算机")==0)
field[4]=field[0];
}
fseek(fp,head.head_num+0l,0);
for(i=1,j=1;i<=head.num;i++)
{
fread(&Flag,1,1,fp);
if(Flag==32)
{
fseek(fp,head.head_num+(i-1)*head.record_long+field[1].begin+0l,0);
for(k=0;k<=19;k++)
stu[j].name[k]=0;
fread(&stu[j].name,field[1].kuan,1,fp);
for(k=field[1].kuan-1;k>=0;k--)
if(stu[j].name[k]==32)
stu[j].name[k]=0;
else break;
for(k=0;stu[j].name[k];k++)
{
if(stu[j].name[k]==32)
{
for(a=k;stu[j].name[a];a++)
stu[j].name[a]=stu[j].name[a+1];
k--;
}
}
fseek(fp,head.head_num+(i-1)*head.record_long+field[2].begin+0l,0);
for(k=0;k<=19;k++)
score[k]=0;
fread(score,field[2].kuan,1,fp);
stu[j].english=atoi(score);
fseek(fp,head.head_num+(i-1)*head.record_long+field[3].begin+0l,0);
for(k=0;k<=19;k++)
score[k]=0;
fread(score,field[3].kuan,1,fp);
stu[j].math=atoi(score);
fseek(fp,head.head_num+(i-1)*head.record_long+field[4].begin+0l,0);
for(k=0;k<=19;k++)
score[k]=0;
fread(score,field[4].kuan,1,fp);
stu[j].computer=atoi(score);
stu[j].numc=(stu[j].math+stu[j].english+stu[j].computer)/3;
j++;
fseek(fp,head.head_num+i*head.record_long+0l,0);
}
else fseek(fp,head.head_num+i*head.record_long+0l,0);
}
N=j-1;
if(N%3==0)
page=N/3-1;
else page=N/3;
fclose(fp);
}
void fanye()
{
U p;
int i=0;
void *j;
unsigned int size;
int x,y,button,x1,y1,x2,y2,flag,a;
char name1[3][5]={"P","N","E"},bing[]={"饼状图"},bing1[]={"(Y)"};
cleardevice();
setcolor(15);
settextstyle(0,0,1);
x1=x=319,y1=y=339,button=0;
cursor_yxy(x,y);
setfillstyle(1,11);
cleardevice();
huatu(0);
size=imagesize(x1,y1,x1+10,y1+15);
j=malloc(size);
getimage(x1,y1,x1+10,y1+15,j);
putimage(x,y,k,0);
while(1)
{
read_yxy(&x,&y,&button);
if(bioskey(1))
p.key=bioskey(0);
else p.key=0;
if(p.c[1]==0x12)
{
exit(0);
}
else if(p.c[1]==0x19&&i)
{
huatu(--i);
free(j);
size=imagesize(x,y,x+10,y+15);
j=malloc(size);
getimage(x,y,x+10,y+15,j);
}
else if(p.c[1]==0x31&&i<page)
{
huatu(++i);
free(j);
size=imagesize(x,y,x+10,y+15);
j=malloc(size);
getimage(x,y,x+10,y+15,j);
}
else if(p.c[1]==0x15)
{
yuanbing();
}
if(x==x1&&y==y1&&!button)
{
if(x<630)
putimage(x,y,k,0);
continue;
}
else
{
putimage(x1,y1,j,0);
free(j);
size=imagesize(x,y,x+10,y+15);
j=malloc(size);
getimage(x,y,x+10,y+15,j);
cursor_yxy(x,y);
}
if(button)
for(a=1;a<=3;a++)
delay(30000);
if((x<240||x>280&&x<320||x>360&&x<400||x>440||y>420||y<380||i==0||i==page)&&(x>600||x<525||y>423||y<390))
{
setcolor(4);
settextstyle(0,0,3);
for(flag=1;flag<=3;flag++)
outtextxy(170+flag*80,390,name1[flag-1]);
settextstyle(0,0,1);
disphz(530,400,&bing[0],4);
disphz(530+20,400,&bing[2],4);
disphz(530+30,400,&bing[4],4);
outtextxy(575,405,bing1);
}
flag=0;
if(x>=240&&x<=280&&y>=380&&y<=420)
{
if(button&&i)
{
huatu(--i);
free(j);
size=imagesize(x,y,x+10,y+15);
j=malloc(size);
getimage(x,y,x+10,y+15,j);
}
if(i)
flag=1;
}
else if(x>=320&&x<=360&&y>=380&&y<=420)
{
if(button&&i<page)
{
huatu(++i);
free(j);
size=imagesize(x,y,x+10,y+15);
j=malloc(size);
getimage(x,y,x+10,y+15,j);
}
if(i<page)
flag=2;
}
else if(x>=400&&x<=440&&y>=380&&y<=420)
{
if(button)
{
exit(0);
}
flag=3;
}
else if(x>=525&&x<=600&&y>=390&&y<=423)
{
if(button)
yuanbing();
flag=4;
}
if(flag)
{
setcolor(11);
settextstyle(0,0,3);
switch(flag)
{
case 1:outtextxy(170+flag*80,390,name1[flag-1]);break;
case 2:outtextxy(170+flag*80,390,name1[flag-1]);break;
case 3:outtextxy(170+flag*80,390,name1[flag-1]);break;
}
if(flag==4)
{
settextstyle(0,0,1);
disphz(530,400,&bing[0],11);
disphz(530+20,400,&bing[2],11);
disphz(530+30,400,&bing[4],11);
outtextxy(575,405,bing1);
}
}
if(x<630)
putimage(x,y,k,0);
y1=y,x1=x;
}
}
void huatu(int i)
{
int j=0,k,g,m,n;
char name1[3][5]={"P","N","E"},name[3][5]={"前翻","后翻","退出"},f[5]={0};
char cutline[3][9]={"计算机","英语","数学"};
char zhi[]={"请按下"},shi[]={"退出"},bing[]={"饼状图"},bing1[]={"(Y)"};
cleardevice();
setcolor(15);
setfillstyle(1,15);
rectangle(0,0,639,479);
floodfill(10,10,15);
setcolor(0);
settextstyle(0,0,1);
setfillstyle(1,14);
bar3d(525,390,600,423,4,1);
disphz(530,400,&bing[0],4);
disphz(530+20,400,&bing[2],4);
disphz(530+30,400,&bing[4],4);
setcolor(4);
outtextxy(575,405,bing1);
setcolor(0);
line(115,85,120,80);
line(125,85,120,80);
line(50,330,550,330);
outtextxy(552,333,"x");
line(545,325,550,330);
line(545,335,550,330);
line(120,80,120,390);
outtextxy(108,75,"y");
settextstyle(0,0,1);
line(117,130,120,130);
outtextxy(90,130,"100");
line(117,180,120,180);
outtextxy(90,180,"75");
line(117,230,120,230);
outtextxy(90,230,"50");
line(117,280,120,280);
outtextxy(90,280,"25");
rectangle(88,30,240,50);
for(j=0;zhi[j];j+=2)
disphz(100+j*12,32,&zhi[j],0);
settextstyle(0,0,2);
outtextxy(170,33,name1[2]);
for(j=0;shi[j];j+=2)
disphz(192+j*12,32,&shi[j],0);
rectangle(520,100,600,165);
for(j=0;j<3;j++)
{
if(j==0)
{
disphz(530,105,&cutline[0][0],0);
disphz(530+20,105,&cutline[0][2],0);
disphz(530+30,105,&cutline[0][4],0);
}
else for(m=0;cutline[j][m];m+=2)
disphz(530+m*12,105+j*20,&cutline[j][m],0);
rectangle(580,110+j*20,590,115+j*20);
switch(j)
{
case 0:n=1;break;
case 1:n=6;break;
case 2:n=2;break;
}
setfillstyle(1,n);
floodfill(581,111+j*20,0);
}
rectangle(520,200,600,265);
for(j=0;j<3;j++)
{
for(m=0;name[j][m];m+=2)
disphz(555+m*12,205+j*20,&name[j][m],0);
setcolor(0);
settextstyle(0,0,1);
for(m=0;m<3;m++)
outtextxy(530,205+m*25,name1[m]);
}
setcolor(0);
settextstyle(0,0,1);
if(i==page&&N%3==0||i!=page)
g=3;
else g=N%3;
for(j=1;j<=g;j++)
{
for(m=0;stu[i*3+j].name[m];m+=2)
disphz(170+120*(j-1)+m*20,340,&stu[i*3+j].name[m],0);
setfillstyle(1,1);
bar3d(150+120*(j-1),330-stu[i*3+j].computer*2,180+120*(j-1),330,5,1);
floodfill(171+120*(j-1),330-stu[i*3+j].computer*2-1,0);
floodfill(161+120*(j-1),329,0);
if(stu[i*3+j].computer<10)
f[0]=48+stu[i*3+j].computer,f[1]=0;
else if(stu[i*3+j].computer<100)
f[0]=stu[i*3+j].computer/10+48,f[1]=stu[i*3+j].computer%10+48,f[2]=0;
else f[0]=49,f[1]=f[2]=48,f[3]=0;
outtextxy(160+120*(j-1),330-stu[i*3+j].computer*2-20,f);
setfillstyle(1,6);
bar3d(180+120*(j-1),330-stu[i*3+j].english*2,210+120*(j-1),330,5,1);
floodfill(191+120*(j-1),330-stu[i*3+j].english*2-1,0);
floodfill(191+120*(j-1),329,0);
if(stu[i*3+j].english<10)
f[0]=48+stu[i*3+j].english,f[1]=0;
else if(stu[i*3+j].english<100)
f[0]=stu[i*3+j].english/10+48,f[1]=stu[i*3+j].english%10+48,f[2]=0;
else f[0]=49,f[1]=f[2]=48,f[3]=0;
outtextxy(190+120*(j-1),330-stu[i*3+j].english*2-20,f);
setfillstyle(1,2);
bar3d(210+120*(j-1),330-stu[i*3+j].math*2,240+120*(j-1),330,5,1);
floodfill(221+120*(j-1),330-stu[i*3+j].math*2-1,0);
floodfill(221+120*(j-1),329,0);
if(stu[i*3+j].math<10)
f[0]=48+stu[i*3+j].math,f[1]=0;
else if(stu[i*3+j].math<100)
f[0]=stu[i*3+j].math/10+48,f[1]=stu[i*3+j].math%10+48,f[2]=0;
else f[0]=49,f[1]=f[2]=48,f[3]=0;
outtextxy(220+120*(j-1),330-stu[i*3+j].math*2-20,f);
}
setfillstyle(1,14);
for(j=1;j<=3;j++)
{
bar3d(160+j*80,380,200+j*80,420,3,1);
floodfill(170+j*80,390,0);
}
setfillstyle(1,7);
if(i==0)
floodfill(250,390,0);
else if(i==page)
floodfill(330,390,0);
setcolor(4);
settextstyle(0,0,3);
for(j=1;j<=3;j++)
outtextxy(170+80*j,390,name1[j-1]);
}
void disphz(int x,int y,char *s,int color)
{
char far *p;
char mask[]={0x01,0x02,0x04,0x08};
int i,j,n;
FILE *fp;
char qh,wh;
long offset;
char buffer[DZ*DZ/8];
fp=fopen(HZ,"rb");
qh=*s-0xa0;
wh=*(s+1)-0xa0;
offset=(94L*(qh-1)+wh-1)*DZ*DZ/8;
fseek(fp,offset,0);
fread(buffer,DZ*DZ/8,1,fp);
fclose(fp);
outportb(0x3ce,4);
outportb(0x3c4,2);
p=(char far*)(0xa0000000+80*y+x/8);
for(i=0;i<DZ;i++)
for(j=0;j<DZ/8;j++)
for(n=0;n<4;n++)
{
outportb(0x3cf,n);
outportb(0x3c5,mask[n]);
if((color&mask[n])!=0)
*(p+80*i+j)|=buffer[DZ*i/8+j];
else *(p+80*i+j)&=~(buffer[DZ*i/8+j]);
}
outportb(0x3cf,0);
outportb(0x3c5,0xf);
}
void shub(int x,int y,int color)
{
setcolor(color);
setfillstyle(1,color);
line(x,y,x,y+11);
line(x,y,x+7,y+7);
line(x,y+11,x+2,y+9);
line(x+7,y+7,x+5,y+7);
line(x+2,y+9,x+3,y+13);
line(x+5,y+7,x+6,y+12);
line(x+3,y+13,x+6,y+12);
floodfill(x+1,y+3,color);
}
void cursor_yxy(int x,int y)
{
union REGS r;
struct SREGS s;
r.x.ax=4;
r.x.cx=x;
r.x.dx=y;
int86x(0x33,&r,&r,&s);
}
void read_yxy(int *x,int *y,int *button)
{
union REGS regs;
int x2,y2;
regs.x.ax=3;
int86(0x33,®s,®s);
x2=regs.x.cx;
y2=regs.x.dx;
*button=regs.x.bx;
*x=x2;
*y=y2;
}
void line_yxy(int *x,int y,int color,int change)
{
setcolor(color);
moveto(*x,y);
lineto(*x,y+16);
*x=*x+change;
}
void dayin_yxy(int k,int y,struct S * d)
{
char name[2]={0};
while(1)
{
name[0]=(*d).c;
outtextxy(k,y,name);
if((*d).next==NULL||k>518)
break;
d=(*d).next;
k+=18;
}
}
void mysound(double freq)
{
int i;
U count;
if(freq)
{
count.key=DIV/freq;
outportb(0x43,0xb6);
outportb(0x42,count.c[0]);
outportb(0x42,count.c[1]);
bits=inportb(0x61);
outportb(0x61,bits|3);
}
}