那位帮我修改一下~~~麻烦了!
#include<string.h>
#include<stdio.h>
#include<conio.h>
#include<dos.h>
void blank();
void book();
void box();
void unit();
main()
{ int i,j,k1,k=0,a2=0,b,d,g,n,s,r,q,a1,a3;
char c[3000],m[100][81],*fname="c:\\cetp\\txt\\xunitx.txt", z [81],ch1,ch2;
struct time *t1=-1,*t2=-1;
float x,y,e,f;
FILE *fp;
while(1)
{
book();
ch1=getch();
if('1'<=ch1 && ch1<='2')
{
unit();
ch2=getch();
if('1'<=ch2 && ch2<='9')
{ fname[12]=ch1;
fname[17]=ch2;
if((fp=fopen(fname,"r"))==NULL)
{ printf("open file error!");
exit(0);
}
while(!feof(fp))
{ fgets(c,3000,fp);
while(strlen(c)>0)
{ n=strlen(c);
if(n>76)
{ for(i=76;i>1;i--)
if(c=='')
break;
}
else i=n;
strncpy(m[k],c,i);
m[k++]==0;
strcpy(c,&c);
}
}
fclose(fp);
gotoxy(1,1);
blank();
gotoxy(1,1);
a1=k/21;
for(k1=0;k1<=a1;k1++)
{ gotoxy(1,1);
n=2;
for(i=0;i<=10;i++)
{ if(a2>=k) break;
gotoxy(1,(i+1)*2-1);
puts(m[i+k1*11]);
a2++;
}
e=0;
f=0;
for(q=1;q<12;q++)
{ textcolor(RED);
gotoxy(1,23);
for(j=1;j<=80;j++)
cprintf("%c",196);
gotoxy(50,24);
printf("speed %2f%",e);
gotoxy(50,25);
printf("accuracy %3f%",f);
d=0;
a3=strlen(m[k1*11+q-1]);
z[a3]=0;
gettime(t1);
for(s=1;s<=80;s++)
{
gotoxy(s,n);
textbackground(1);
textcolor(7);
r=getch();
z[s]=r;
if(z[s]==m[k1*11+q-1][s-1])
cprintf("%c",z[s]);
else if(z[s]=='\b')
{ s--;
if(z[s]!=m[k1*11+q-1][s-1]) d--;
gotoxy(s,n);
s--;
printf("%c",0);
}
else if(z[s]==27) exit(0);
else if(z[s]!=m[k1*11+q-1][s-1] && z[s]==' ')
{ textbackground(GREEN);
cprintf(" ");
}
else
{ textcolor(GREEN);
cprintf("%c",z[s]);
d++;
}
if(s==a3) break;
}
gotoxy(4,1);
gettime(t2);
b=strlen(m[k1*11+q-1]);
n=n+2;
x=t1->ti_min*60+t1->ti_sec+t1->ti_hund/100;
y=t2->ti_min*60+t2->ti_sec+t2->ti_hund/100;
e=b/(y-x)*100;
f=(b-d)/b*100;
}
}
}
}
clrscr();
blank();
textcolor(GREEN);
gotoxy(20,13);
cprintf("press any key to continue,press Esc exit");
if(getch()==27) exit(0);
}
}
void blank()
{ int i;
textbackground(1);
for(i=1;i<=2000;i++)
cprintf(" ");
}
void box(x1,y1,x2,y2) /*画边框*/
{ int i;
char c;
blank();
textcolor(7);
gotoxy(x1,y1); cprintf("%c",201);
gotoxy(x1,y2); cprintf("%c",200);
gotoxy(x2,y1); cprintf("%c",187);
gotoxy(x2,y2); cprintf("%c",188);
for(i=y1+1;i<=y2-1;i++)
{ gotoxy(x1,i);
cprintf("%c",186);
gotoxy(x2,i);
cprintf("%c",186);
}
for(i=x1+1;i<=x2-1;i++)
{ gotoxy(i,y1);
cprintf("%c",205);
gotoxy(i,y2);
cprintf("%c",205);
}
}
void book()
{ int i;
box(30,7,50,18);
for(i=1;i<=10;i++)
{ gotoxy(35,i+7);
cprintf("BOOK %d",i);
}
}
void unit()
{ int i;
box(30,7,50,18);
for(i=1;i<=10;i++)
{ gotoxy(35,i+7);
cprintf("UNIT %d",i);
}
}
[此贴子已经被作者于2006-8-16 10:39:58编辑过]