#2
by kikn » 4年前
コード:
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <time.h>
int sleep(int x)
{
clock_t start,now;
now = start = clock( );
while(1000 * (now-start) / CLOCKS_PER_SEC < x){
now = clock( );
if(now == (clock_t)-1){
return 0;
}
}
return 1;
}
int main(void)
{
FILE *fp;
char str[256];
int len,i,ch,a,b,nyu,mo;
clock_t start,end;
double jikan,at,spd;
nyu = 0;
mo = 0;
printf("5");
fflush(stdout);
sleep(1000);
printf("\r4 ");
fflush(stdout);
sleep(1000);
printf("\r3 ");
fflush(stdout);
sleep(1000);
printf("\r2 ");
fflush(stdout);
sleep(1000);
printf("\r1 ");
fflush(stdout);
sleep(1000);
printf("\r");
fflush(stdout);
sleep(100);
fp = fopen("data.txt","r");
if(fp == NULL){
printf("File Open Error\n");
return -1;
}
printf("以下の文字列をタイプしてください.\n");
start = clock( );
while(fgets(str,256,fp) != NULL){
len = strlen(str);
str[len-1] = '\0';
len = len -1;
for(i = 0; i< len; i++){
printf("%s \r",&str[i]);
fflush(stdout);
while(1){
ch = getch( );
if(ch == str[i]){
break;
end = clock( );
jikan = (double)(end - start) / CLOCKS_PER_SEC;
at = 100 * mo / nyu;
printf("出題文字数は%d(key)です. 全入力数は%d(key)です. 正打率は%.1lf(%)です.",mo,nyu,at);
spd = mo * 60 / jikan;
printf("\n所要時間は%.1lf(sec)です.",jikan);
printf(",タイプスピードは%.1lf(key/min)です.",spd);
}
}
}
}
fclose(fp);
if(at >=100 && spd <=200){
printf("\nSランク. \n");
}else if(at >=80 && spd <=190){
printf("\nAランク \n");
}else if(at >=70 && spd <=180){
printf("\nBランク \n");
}else if(at >=60 && spd <=175){
printf("\nCランク \n");
}else if(at >=50 && spd <=160){
printf("\nDランク \n");
}else {
printf("\nEランク \n");
}
return 0;
}
[code]
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <time.h>
int sleep(int x)
{
clock_t start,now;
now = start = clock( );
while(1000 * (now-start) / CLOCKS_PER_SEC < x){
now = clock( );
if(now == (clock_t)-1){
return 0;
}
}
return 1;
}
int main(void)
{
FILE *fp;
char str[256];
int len,i,ch,a,b,nyu,mo;
clock_t start,end;
double jikan,at,spd;
nyu = 0;
mo = 0;
printf("5");
fflush(stdout);
sleep(1000);
printf("\r4 ");
fflush(stdout);
sleep(1000);
printf("\r3 ");
fflush(stdout);
sleep(1000);
printf("\r2 ");
fflush(stdout);
sleep(1000);
printf("\r1 ");
fflush(stdout);
sleep(1000);
printf("\r");
fflush(stdout);
sleep(100);
fp = fopen("data.txt","r");
if(fp == NULL){
printf("File Open Error\n");
return -1;
}
printf("以下の文字列をタイプしてください.\n");
start = clock( );
while(fgets(str,256,fp) != NULL){
len = strlen(str);
str[len-1] = '\0';
len = len -1;
for(i = 0; i< len; i++){
printf("%s \r",&str[i]);
fflush(stdout);
while(1){
ch = getch( );
if(ch == str[i]){
break;
end = clock( );
jikan = (double)(end - start) / CLOCKS_PER_SEC;
at = 100 * mo / nyu;
printf("出題文字数は%d(key)です. 全入力数は%d(key)です. 正打率は%.1lf(%)です.",mo,nyu,at);
spd = mo * 60 / jikan;
printf("\n所要時間は%.1lf(sec)です.",jikan);
printf(",タイプスピードは%.1lf(key/min)です.",spd);
}
}
}
}
fclose(fp);
if(at >=100 && spd <=200){
printf("\nSランク. \n");
}else if(at >=80 && spd <=190){
printf("\nAランク \n");
}else if(at >=70 && spd <=180){
printf("\nBランク \n");
}else if(at >=60 && spd <=175){
printf("\nCランク \n");
}else if(at >=50 && spd <=160){
printf("\nDランク \n");
}else {
printf("\nEランク \n");
}
return 0;
}
[/code]