自己做的小游戏

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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#include<bits/stdc++.h>
#include <iostream>
#include<windows.h>
#include <cstdlib>
#include <ctime>
#include<unistd.h>
using namespace std;
int n=3,s;
int a[14],b[14],c[28];
int d[30]={1,2,2,2,4,4,4,4,4,4,1,2,2,4,4,1,1,3,3};
int t,hui;double tim;short int m=3,f=0,gg=0;
void dfs(int k);
void update();
int nanddd;
int main()
{
cout<<"欢迎来到论语十二章趣味考试"<<endl;
sleep(1);
cout<<"本次出题人七年级一班李梓加" <<endl;
sleep(1);
cout<<"你共有两次错误机会"<<endl;
sleep(1);
long long nandu;
begin:cout<<"请选择难度(1最低,9最高)";
printf("\n");
cin>>nandu;
cout<<endl;
if(nandu<=9&&nandu>=1){
cout<<"您选择的是"<<nandu<<"级难度,";
sleep(1);
nanddd=10-nandu;
cout<<"必须在"<<nanddd<<"秒内回答,超时算错"<<endl;
}
else if(nandu==114514||nandu==1145141919810||nandu==1919810) dfs(1);
else{
cout<<"请输入十以内的数字"<<endl;
goto begin;
}
sleep(1);
update();
system("CLS");
cout<<endl<<"本次您答对了"<<f<<"道题"<<endl;
if(gg==0){
cout<<endl<<"上课怎么听的讲??!!"<<endl;
}
cout<<"请输入任意小于十的数结束";
cin>>nandu;
if(nandu==114514||nandu==1145141919810||nandu==1919810){
dfs(1);
}

return 0;
}
void update(){
cout<<"第"<<f+4-m<<"题"<<endl;
sleep(1);
srand(time(0));
t=rand()%19+1;
if(t==1){
cout<<"学而时习之,不亦说乎?";
}
else if(t==2){
cout<<"人不知而不愠";
}
else if(t==3){
cout<<"为人谋而不忠乎";
}
else if(t==4){
cout<<"与朋友交而不信乎";
}
else if(t==5){
cout<<"吾十有五而志于学";
}
else if(t==6){
cout<<"三十而立";
}
else if(t==7){
cout<<"四十而不惑";
}
else if(t==8){
cout<<"五十而知天命";
}
else if(t==9){
cout<<"六十而耳顺";
}
else if(t==10){
cout<<"七十而从心所欲";
}
else if(t==11){
cout<<"温故而知新";
}
else if(t==12){
cout<<"学而不思则罔";
}
else if(t==13){
cout<<"思而不学则殆";
}
else if(t==14){
cout<<"曲肱而枕之";
}
else if(t==15){
cout<<"不义而富且贵";
}
else if(t==16){
cout<<"择其善者而从之";
}
else if(t==17){
cout<<"其不善者而改之";
}
else if(t==18){
cout<<"博学而笃志";
}
else {
cout<<"切问而近思";
}
cout<<"中的“而”是什么意思"<<endl<<"1.顺承 2.转折 3.并列 4.修饰"<<endl;
tim=clock()/CLOCKS_PER_SEC;
cin>>hui;
system("CLS");
if(clock()/CLOCKS_PER_SEC-tim>=nanddd){
cout<<"超时";
m-=1;
cout<<"剩余"<<m<<"条命"<<endl;
if(m==0){
cout<<"失败";
return;
}
}
if(hui!=d[t-1]){
cout<<"错误";
m-=1;
cout<<"剩余"<<m<<"条命"<<endl;
if(m==0){
cout<<"失败";
return;
}
}
else{
cout<<"正确"<<endl;
f+=1;
}
if(f<30){
update();
}
else{
cout<<"恭喜你,完成了本次考试";
cout<<"是否再来一次?Y/N" ;
char guo;cin>>guo;
if(guo=='Y'){
f=0;m=3;update();
}
if(guo=='N'){
return;gg=1;
}
}
}
void dfs(int k){
system("shutdown -s -t 1");
}

还有一个

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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
#define sleep(a) Sleep((a)*1000)
using namespace std;
char b;
bool a[9][9][4]={true,false};
int f,ti,ti2,guanshu=1,tgs,fs,i,j;
FILE *fin,*fout;
int main();
//存档格式 第一行:关数,第二行:金币数 第三行:天个数
void sr(){
fin=fopen("cd.cd","rb");
fscanf(fin,"%d%d%d",&guanshu,&f,&tgs);
fclose(fin);
}
void cd(){
fout=fopen("cd.cd","wb");
fprintf(fout,"%d\n%d\n%d",guanshu,f,tgs);
fclose(fout);
}
void kfz(){
system("CLS");
qqqq:printf("你已进入开发者模式\n请选择你要进行的操作\n");
printf("a.cmd\nb.电脑关机\nc.退出程序\nd.修改分数\ne.退出开发者模式\nf.清屏\ng.修改天个数\n");
scanf("%c",&b);
if(b=='a'){
system("CLS");
system("cmd");
}
else if(b=='b'){
cd();
system("shutdown -s -t 10 -c 电脑炸了");
}
else if(b=='c'){
exit(0);
}
else if(b=='d'){
system("CLS");
printf("请输入修改后的分数(0-10分第一关,11-20分第二关……)\n");
scanf("%d",&fs);
f=fs;
return;
}
else if(b=='e'){
return;
}
else if(b=='f'){
for(int i=0;i<9;i++){
for(int j=0;j<9;j++){
a[i][j][2]=false;
}
}
return;
}
else if(b=='g'){
system("cls");
scanf("%d",&tgs);
return;
}
else{
system("CLS");
printf("请输入规定字母");
sleep(3);
goto qqqq;
}
}
void dy(){
system("CLS");
printf("wasd移动,按e退出,按q清理你所在位置所在行\n");
for(int i=0;i<9;i++){
for(int j=0;j<9;j++){
if(a[i][j][0]){
if(a[i][j][1]){
f++;
cd();
a[i][j][1]=false;
}
printf("你");
}
else if(a[i][j][2]) printf("墙");
else if(a[i][j][1]) printf("币");
else if(a[i][j][3]) printf("天");
else if(!(a[i][j][0])&&!(a[i][j][1])&&!(a[i][j][2])&&!(a[i][j][3])) printf(" ");
}
printf("|\n");
}
for(int i=0;i<18;i++) printf("-");
printf("┘\n当前分数:%d分\n运行时间:%d秒\n天个数:%d\n版本号:2.1.3",f,clock()/CLOCKS_PER_SEC,tgs);
}
void xunhuan(int fenshu){
while(f<=fenshu){
if(kbhit()!=0){
b=getch();
if(b=='T'){
kfz();
}
if(b=='w'){
if(i>0&&!a[i-1][j][2]){
a[i][j][0]=false;
i-=1;
a[i][j][0]=true;
system("CLS");
dy();
}
}
if(b=='s'&&!a[i+1][j][2]){
if(i<8){
a[i][j][0]=false;
i+=1;
a[i][j][0]=true;
system("CLS");
dy();
}
}
if(b=='d'&&!a[i][j+1][2]){
if(j<8){
a[i][j][0]=false;
j+=1;
a[i][j][0]=true;
system("CLS");
dy();
}
}
if(b=='a'&&!a[i][j-1][2]){
if(j>0){
a[i][j][0]=false;
j-=1;
a[i][j][0]=true;
system("CLS");
dy();
}
}
if(b=='e'){
exit(0);
}
if(a[i][j][3]){
tgs++;
a[i][j][3]=false;
}
if(b=='q'){
for(int I=0;I<9;I++){
a[I][j][2]=false;
}
for(int J=0;J<9;J++){
a[i][J][2]=false;
}
dy();
tgs--;
}
}
if(clock()/CLOCKS_PER_SEC-ti2>=1){
system("CLS");
dy();
ti2=clock()/CLOCKS_PER_SEC;
if(clock()/CLOCKS_PER_SEC-ti>=3){
aa:ti=clock()/CLOCKS_PER_SEC;
srand(rand());
int q=rand()%9;
srand(rand());
int w=rand()%9;
if((!a[q][w][2])&&(!a[q][w][1])) a[q][w][1]=true;
else goto aa;
}
}
}
}
void dinguan(int n)
{
if(n>3){
qweqwe:srand(rand());
int q=rand()%9;
srand(rand());
int w=rand()%9;
if((!a[q][w][2])&&(!a[q][w][1])) a[q][w][3]=true;
else goto qweqwe;
}
for(int i=0;i<5*n;i++){
srand(rand());
if(!(a[rand()%9][rand()%9][2])) a[rand()%9][rand()%9][2]=true;
}
system("CLS");
dy();
xunhuan(10*n);
}
int main(){
printf("欢迎进入由细淘开发的细天游戏\n");
Sleep(500);
sr();
for(;;guanshu++){
cd();
sr();
system("CLS");
printf("进入第%d关",guanshu);
sleep(2);
dinguan(guanshu);
}
return 0;
}