童年钢琴谱简易版数字:指法练习c程序设计

来源:百度文库 编辑:神马品牌网 时间:2024/05/03 06:05:09
要求;(1)用c语言编写
(2)能计算打字的正确数与错误数和用户的最高得分

#include<string.h>
#include<alloc.h>
#include<dos.h>
#define SIZE 30
win()
{
clrscr();
gotoxy(20,2);printf("*------------------------------*");
gotoxy(20,3);printf("* Fingering Training System *");
gotoxy(20,4);printf("* Designed By PrOve *");
gotoxy(20,5);printf("* 2005-09-06 *");
gotoxy(20,6);printf("*------------------------------*");
gotoxy(16,7);printf("...Press any key to entry the System...");
getch();
clrscr();
gotoxy(5,2);printf("Input original text:\n");
gotoxy(5,22);printf("------------------------------------------------------");
gotoxy(5,23);printf(" CorrectRate:%");
gotoxy(33,23);printf("Speed: w/s");

}
main()
{
char o1[150],o2[SIZE],o3[SIZE],o4[SIZE];/*每一行原文,最多150字符*/
char i1[150],i2[SIZE],i3[SIZE],i4[SIZE];/*每一行输入*/
int i;
long error = 0,correct = 0;
float crate;
double speed;
double ti;
char flag;
struct time t1,t2;

start:win();
gotoxy(5,4);printf("------------------------------------------------------");
gotoxy(5,3);gets(o1);
gotoxy(5,6);printf("------------------------------------------------------");
gotoxy(5,5);gets(o2);strcat(o1,o2);
gotoxy(5,8);printf("------------------------------------------------------");
gotoxy(5,7);gets(o3);strcat(o1,o3);
gotoxy(5,10);printf("------------------------------------------------------");
gotoxy(5,9);gets(o4);strcat(o1,o4);
gotoxy(5,11);printf("Start Now!\n");
gotoxy(5,13);printf("------------------------------------------------------");
gettime(&t1); /*计时开始*/
gotoxy(5,12);gets(i1);
gotoxy(5,15);printf("------------------------------------------------------");
gotoxy(5,14);gets(i2);strcat(i1,i2);
gotoxy(5,17);printf("------------------------------------------------------");
gotoxy(5,16);gets(i3);strcat(i1,i3);
gotoxy(5,19);printf("------------------------------------------------------");
gotoxy(5,18);gets(i4);strcat(i1,i4);
gettime(&t2);/*计时结束*/

for(i = 0;i <strlen(o1);i++)
{
if(o1[i] != i1[i])
error++;
else
correct++;
}
crate =(float) correct / (float)strlen(i1) * 100;
ti = (double)((t2.ti_hour * 3600 + t2.ti_min * 60 + t2.ti_sec ) - (t1.ti_hour * 3600 + t1.ti_min * 60 + t1.ti_sec ));
speed = (double)strlen(i1) / (double)ti;
gotoxy(20,23);printf("%f",crate);
gotoxy(40,23);printf("%lf",speed);
gotoxy(5,20);printf("Continue or Not(Y/N) ?");
flag = getch();
if(flag == 'y' || flag == 'Y')
goto start;
else
{
clrscr();
gotoxy(26,7);printf("Welcome to use!");
gotoxy(19,8);printf("...Press any key to exit...");
getch();
exit(1);
}
getch();
}