c程序测打字速度 急!!!
c程序编程序启动时显示”Thequickbrownfoxjumpsoverthelazydog.”,输入光标位于本行结束。用户按回车键后,进行输入,并开始计时。当用户再次...
c程序编程序启动时显示”Thequick brown fox jumps over the lazy dog.”,输入光标位于本行结束。用户按回车键后,进行输入,并开始计时。当用户再次按回车键时,计时停止。显示本次所用时间。继续下一次速度测试。
下面是我编写的程序,但是第二次循环按回车键后电脑显示有问题,要退出。。。
求大侠帮忙 急!!!!!
#include<stdio.h>#include<time.h>
int gamestart();
#define NUMBER 100
int main()
{
char a = '\n';
do
{
printf("the quick brown fox jumps over the lazy dog.");
gamestart();
scanf("%c",a);
}
while(a == '\n');
return 0;
}
int gamestart()
{
double tm1,tm2, result;
char c;
int i;
char b[NUMBER];
scanf("%c",&c);
if(c == '\n')
{
tm1 = time(NULL);
}
for(i=0;i<NUMBER;i++){
scanf("%c",&b[i]);
if(b[i]=='\n')
break;
}
tm2 = time(NULL); result = tm2 - tm1;
printf("您所用时间为%lf \n",result);
return 0;
} 展开
下面是我编写的程序,但是第二次循环按回车键后电脑显示有问题,要退出。。。
求大侠帮忙 急!!!!!
#include<stdio.h>#include<time.h>
int gamestart();
#define NUMBER 100
int main()
{
char a = '\n';
do
{
printf("the quick brown fox jumps over the lazy dog.");
gamestart();
scanf("%c",a);
}
while(a == '\n');
return 0;
}
int gamestart()
{
double tm1,tm2, result;
char c;
int i;
char b[NUMBER];
scanf("%c",&c);
if(c == '\n')
{
tm1 = time(NULL);
}
for(i=0;i<NUMBER;i++){
scanf("%c",&b[i]);
if(b[i]=='\n')
break;
}
tm2 = time(NULL); result = tm2 - tm1;
printf("您所用时间为%lf \n",result);
return 0;
} 展开
展开全部
试试下面的:
#include<stdio.h>
#include<conio.h>
#include<time.h>
int gamestart();
int main()
{
char a;
do
{
printf("The quick brown fox jumps over the lazy dog.\n");
gamestart();
printf("Enter y to try again,or other character to quit game:");//输入y重新开始,其他字符结束退出
a=getche();
printf("\n");
}while(a=='y');
return 0;
}
int gamestart()
{
time_t tm1,tm2;
double result;
char c;
int i;
do{
printf("Please press [enter] to start!\n");//按回车开始
c=getch();
}while(c!=13);
tm1=time(NULL);
for(i=0,c=' ';c!='\n';i++) scanf("%c",&c);
tm2 = time(NULL);
result = difftime(tm2,tm1);
printf("Input %d characters in %.0f seconds.\n",--i,result);
return 0;
}
#include<stdio.h>
#include<conio.h>
#include<time.h>
int gamestart();
int main()
{
char a;
do
{
printf("The quick brown fox jumps over the lazy dog.\n");
gamestart();
printf("Enter y to try again,or other character to quit game:");//输入y重新开始,其他字符结束退出
a=getche();
printf("\n");
}while(a=='y');
return 0;
}
int gamestart()
{
time_t tm1,tm2;
double result;
char c;
int i;
do{
printf("Please press [enter] to start!\n");//按回车开始
c=getch();
}while(c!=13);
tm1=time(NULL);
for(i=0,c=' ';c!='\n';i++) scanf("%c",&c);
tm2 = time(NULL);
result = difftime(tm2,tm1);
printf("Input %d characters in %.0f seconds.\n",--i,result);
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询