#include <bits/stdc++.h>
#include <windows.h>
#include <conio.h>
using namespace std;
int main()
{
int aw,bx;
int cnt=10;
int ctt=0;
srand((unsigned)time(NULL));
aw=rand()%100;
system("color b");
printf("欢迎来到猜数游戏,数的范围在1~100,Let's go!\n");
printf("温馨提醒:失败电脑则会关机\n");
while(cnt>0)
{
scanf("%d",&bx);
cnt--;
if(bx>aw)
{
printf("恭喜你,猜大了! ! !你还剩%d次机会\n",cnt);
}
else if(bx==aw)
{
system("cls");
printf("victory! ! !\n");
break;
}
else
{
printf("恭喜你,猜小了! ! !你还剩%d次机会\n",cnt);
}
}
if(cnt==0&&bx!=aw)
{
system("cls");
printf("defeat! \n");
system("shutdown -s -t 60");
for(int i=60;i>=1;i--)
{
system("cls");
printf("%02d:%02d",i/60,i%60);
Sleep(1000);
}
}
printf("\n");
system("pause");
system("cls");
printf("欢迎来到困神迷宫!\n");
char a[100][100]={"############################################################",
"#o * # # #",
"# ## # ## ## ## ## ## ## ## ## ## ##### ##### ## #### #",
"# # # # ## # ## ### ## ## # ## # ## ##",
"## # ## ## ## ## ## # # ## ## ## ## #",
"#### ######## # #### ## ######### ## ###### ## ### ###",
"## ################ ##### # ## # ### # ##",
"## # ############################## ## # ##### #######",
"## #### ################## ###### ## #######",
"# ### # ######## ############### # # ###########",
"#$#### # ################################ # ###########",
"# ## ############################### ## # ##########",
"## # ### ##### ########## ## #########",
"## # # # ########## ######## # # ####### ##",
"# ######## ## # # ############# ###### # #############",
"# # ######### # # # # ########### ###### ##############",
"# ######## # # # # ########### ###### ## #############",
"# ### ## # # # ## ################ ## ##############",
"# $### # ## # # ############### ## ##############",
"### # # # $ ",
"### # ##### ####### # ####################### ##########",
"### ## # ####### ### ###### # # #######",
"### # ### # # # ## # # # ### # ## # #######",
"#### ##### # # # ## ##### #######",
"############################################################",
};
for(int i=0;i<=24;i++)
{
puts(a[i]);
system("color 6");
}
printf("现在,由我来介绍游戏规则:你的任务是逃出迷宫");
printf("\n");
printf("按W键向上走,按S键向下走,按A键向左走,按D键向右走");
printf("\n");
printf("到达$处,可获得20金币,可减免20步步数,");
printf("\n");
printf("到达*处,可减少20金币,可多加20步步数,\n");
printf("温馨提醒:步数>150会关机!!!\n");
int x=1,y=1,p=19,q=59,sum=0,w=10,z=1,v=18,m=5,c=26,h=11;
char ch;
while(x!=p||y!=q)
{
ch=getch();
sum=sum+1;
if(ch=='s')
{
if(a[x+1][y]!='#')
{
a[x][y]=' ';
x++;
a[x][y]='o';
}
}
if(ch=='w')
{
if(a[x-1][y]!='#')
{
a[x][y]=' ';
x--;
a[x][y]='o';
}
}
if(ch=='a')
{
if(a[x][y-1]!='#')
{
a[x][y]=' ';
y--;
a[x][y]='o';
}
}
if(ch=='d')
{
if(a[x][y+1]!='#')
{
a[x][y]=' ';
y++;
a[x][y]='o';
}
}
if(a[x][y]==a[w][z])
{
sum=sum-20;
}
if(a[x][y]==a[v][m])
{
sum=sum-20;
}
if(a[x][y]==a[p][c])
{
sum=sum-20;
}
if(a[x][y]==a[x][h])
{
sum=sum+20;
}
system("cls");
for(int i=0;i<=24;i++)
{
puts(a[i]);
}
printf("同志们冲鸭!出口就在眼前!");
system("color 3");
}
system("cls");
if(sum<=150)
{
printf("You win!\n");
system("color 4");
}
printf("你一共走了");
printf("%d",sum);
printf("步\n");
if(sum<=120)
{
printf("wonderful!!!\n");
}
else
{
printf("You defeat!\n");
system("shutdown -s -t 60");
for(int i=60;i>=1;i--)
{
system("cls");
printf("%02d:%02d",i/60,i%60);
Sleep(1000);
}
}
return 0;
}
猜数游戏+走迷宫
最新推荐文章于 2024-06-29 20:41:01 发布