1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 #include<graphics.h> 5 #include<conio.h> 6 #include<math.h> 7 #include<dos.h> 8 #define S 16 9 #define bgi "c:\bgi" 10 #define ppqq 30000 11 #define PI acos(-1.0) 12 #define HZK "c:\tc\hzk\hzk16" 13 long app=0,opple=0,Akm=0,sdibt=0; 14 int x=60,y=80; 15 char app1[123]; 16 void cursor();/*被调函数的生命声明*/ 17 void dispz(); 18 void my_sound(); 19 void load_pic(); 20 void save_pic(); 21 void input(); 22 void newxy(); 23 void read_date(); 24 long Mouse_operate(); 25 void disphz(); 26 int oi=0; 27 struct HEAD 28 { 29 char file_type; 30 char file_date[3]; 31 long file_num; 32 short file_width; 33 short rec_width; 34 } head; 35 struct file 36 { 37 char field_name[10]; 38 char field_type[2]; 39 long field_start; 40 char field_width; 41 char field_dight; 42 } Fild; 43 struct ranklist 44 { 45 char name[123]; 46 double english; 47 double math; 48 double sum; 49 double computer; 50 } p; 51 union input 52 { 53 int key; 54 char cmp[2]; 55 } key; 56 int cmp(const void *a,const void *b)/*按照成绩排序,总分第一优先级,次优先级是英语成绩*/ 57 { 58 struct ranklist *c=(struct ranklist *)a; 59 struct ranklist *d=(struct ranklist *)b; 60 if(c->sum==d->sum) 61 return d->english-c->english; 62 return d->sum-c->sum; 63 } 64 65 void read_date(struct ranklist *student)/*数据库的读取及文本框的输入*/ 66 { 67 long n,i,j,m,p3,cpu,flag=0,lenth=0,k=0; 68 char str[134],kk[123],arr[]= {"Please input your secret"},ch; 69 double score; 70 int kkp; 71 char name[123]; 72 long start1,start2,start3,count=0,p1,p2,p4,start4; 73 FILE *fp; 74 int gmode,gdriver=DETECT; 75 76 initgraph(&gdriver,&gmode,bgi); 77 m=app; 78 79 while(1)/*判断文件是否能打开*/ 80 { 81 if(Akm==0) 82 { 83 cleardevice(); 84 setcolor(4); 85 setcolor(15); 86 bar(110,120,310,150); 87 disphz(110,100,"请输入数据库文件名,回车键结束",15,1); 88 disphz(110,180,"提示",15,1); 89 setcolor(15); 90 outtextxy(142,215,"1."); 91 disphz(155,210,"可以带盘符和路径,如:",15,1); 92 setcolor(15); 93 outtextxy(380,215,"c:\tc\ss.dbf"); 94 setcolor(15); 95 outtextxy(145,235,"2.dbf"); 96 disphz(185,230,"可省略",15,1); 97 98 do 99 { 100 flag++; 101 if(flag%2==0) 102 setcolor(15); 103 else 104 setcolor(0); 105 line(110+lenth*16,150,110+lenth*16+10,150); 106 delay(200); 107 } 108 while(!kbhit()); 109 setcolor(15); 110 line(110+lenth*16,150,110+lenth*16+10,150); 111 } 112 else 113 { 114 setcolor(15); 115 outtextxy(110,135,app1); 116 k=0; 117 setcolor(0); 118 rectangle(270,240,640,370); 119 120 setfillstyle(1,0); 121 floodfill(273,243,0); 122 } 123 Akm++; 124 memset(app1,0,sizeof(app1)); 125 memset(str,0,sizeof(str)); 126 while(1) 127 { 128 129 key.key=bioskey(0); 130 kkp=bioskey(2); 131 ch=key.cmp[0]; 132 if((ch!=8&&ch!=' '&&(ch>='a'&&ch<='z')||((ch>='A'&&ch<='Z')&&(kkp&64||kkp&1||kkp&2))||(ch>='0'&&ch<='9'||ch=='.')||ch=='\'||ch==':'||ch=='_')&&strlen(str)<12)/*输入文本框时非法字符的限制*/ 133 { 134 str[k++]=ch; 135 str[k]='