-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
70 lines (70 loc) · 1.6 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <conio.h>
#include <stdlib.h>
#include<stdio.h>
#include<windows.h>
#include<time.h>
main()
{
int i=1,j,wz,k,flag,score=0;
char a,kb;
printf("请键入任意键开始打字游戏!\n");
system("pause");
system("cls");
srand(time(0));
wz=rand()%50;
a=rand()%26+97;
for(i=0;i<=20;i++){
system("cls");
if(i>=20){
score--;
system("cls");
printf("分数-1!!");
i=0;
a=rand()%26+97;
wz=rand()%50;
Sleep(2000);
continue;
}
if(score<=-3){
system("cls");
printf("YOU DIE");
Sleep(5000);
break;
}else if(score>=10)
{
system("cls");
printf("YOU WIN");
Sleep(5000);
break;
}
printf("score=%d\n-----------------------------------------------------\n",score);
for(j=1;j<i;j++){
printf("\n");
}
for(j=1;j<wz;j++){
printf(" ");
}
putchar(a);
if(kbhit()){
kb=getch();
if(kb==a){
score++;
i=0;
a=rand()%26+97;
wz=rand()%50;
continue;
}else if(kb!=a)
{
score--;
system("cls");
printf("按键错误!分数-1!");
i=0;
a=rand()%26+97;
wz=rand()%50;
Sleep(1000);
continue;
}
}
Sleep(300);
}
}