타자연습 프로그램을 만드는 과제입니다.(리눅스)
제가 어려움을 겪고있는 부분은 실시간으로 정확도와 현재타수를 나오게 하는 부분 입니다.
현재타수는 어떻게 구하긴 했는데 입력한 문자중에 틀린문자를 입력하는것은 현재타수에 포함시킬수 없게 만들어야 합니다.맞은 문자만 현재타수에 포함하라네요.정확도도그렇고 막막합니다....
염치없지만 고수님들의 도움이 필요합니다....
도와주시면 여친생기시고 올해 돈도 많이버실겁니다..
1 #include <stdio.h>
2 #include <time.h>
3 #include <string.h>
4 #include "getche.h"
5 #include <stdlib.h>
6 int main()
7 {
8 char mysent[1000];//타자연습의 입력값저장
9 char longsent[4][10][100]={{"AND THERE WERE NONE",
10 "In the coner of a first-class smoking carriage,Mr.Justice Wargrave,lately retired from the bench.",
11 "ran an interested eye through the political news in the The Times.",
12 "He laid the paper down and glanced out of the window.",
13 "They were running now through Somerset."},
14 {"He glanced at his watch-another two hours to go."
15 ,"He went over in his mind all that had appeared int the papers about Soldier Island."
16 ,"There had been its original purchase by an Amreican millionaire"
17 ,"who was crazy about yatchting-and an account of the luxurious modern house"
18 ,"he had built on this little island off the Devon coast."},
19 {"The unfortunate fact that the new third wife of the American milionaire"
20 ,"was a bad sailor had led to the subsequent putting up of he house and island fo sale."
21 ,"Various glowing advertisements of it had appeared in the papers."
22 ,"Then came the first baldstatement that it had been bought-by a Mr.Owen."
23 ,"After that the rumorous of the gossip writers had strted."},
24 {"Janas knew a fact that it had been purchased by the Admiralty with very hush-hush expriments!"
25 ,"Definitely,Soldier Island was news!"
26 ,"From his pocket Mr.Justice Wargrave drew out a letter."
27 ,"The hand writing was practically illegible."
28 ,"Mr.Justice Wargrave cast back his mind to remember."}};
29 int correct=0; //정확도
30 int x=0,z=0,a=0;
31 int rand_n; //무작위로 긴글을 설정할수 있게함
32 int enter=0;
33 int typing; //현재타수를 구하기위해 총 입력수를 구함
34 char sent[1000]; //랜덤으로 뽑힌 긴 글을 저장
35 time_t start,end;
36 int now=0;
37 int sentsize=strlen(sent); //랜덤으로 뽑힌 긴 글의 문자열 길이
38 srand(time(NULL));
39 rand_n=rand()%4;
40
41 printf(">> 영문 타자 연습 프로그램 : 긴 글 연습 <<\n");
42
43 for(a=0;a<5;a++)
44 {
45 printf("%s\n",longsent[rand_n][a]); //긴 글 출력(5문장을 랜덤으로 반복출력함)
46
47 }
48
49 printf("\n\n");
50
51 time(&start); //시간측정시작
52 now=correct*60/(end-start);
53
54 while(1)
55 {
56 printf("정확도 : %d%% 현재타수 : %d\n",correct,typing*60(end-start);
57 while(z<1000)
58 {
59 mysent[z] =getche();
60 printf("\n\n\n\n\n\n 정확도 : %d%% 현재타수 : %d",correct,typing*60(end-start));
61
62 if(mysent[z] == 27) //ESC를 입력하면 프로그램 종료
63 {
64 printf("\n 프로그램을 종료합니다\n");
65 return 0;
66 }
67 if(mysent[z] == 127) //아스키값 127은 DEL
68 printf("\b \b"); //백스페이스
69
70 if(mysent[z] == '\n')
71 {
72 enter++;
73
74 if(enter==5) //엔터를 다섯번 입력하면 두번째 페이지로 이동
75 {
76 system("clear"); //두번째 페이지를 새로 출력하기위해 화면을 지워줌
77 for(x=0;x<5;x++)
78 printf("%s\n",longsent[rand_n][x]);
79 printf("\n");
80 }
81
82 if(enter == 10) // 긴 글 입력이 완료되면 잠시 멈춰 통계를 보여주고
83 {
84 time(&end); //시간측정 종료
85 typing=strlen(mysent);
86 printf("\n\n");
87 printf("typing : %d\n",typing);
88 printf("정확도 : %d%% 현재타수 : %d\n",correct,typing*60/(end-start));
89 printf("ESC를 누르면 프로그램을 종료합니다");
90 sleep(3);
91 }
92 }
93 z++;
94 }
95 }
96
97 return 0;
98 }
http://autogram.tk/이
중고차 어플리케이션 어떤가요?