c语言吃数游戏

上传人:枫** 文档编号:508022650 上传时间:2022-10-15 格式:DOC 页数:12 大小:40.50KB
返回 下载 相关 举报
c语言吃数游戏_第1页
第1页 / 共12页
c语言吃数游戏_第2页
第2页 / 共12页
c语言吃数游戏_第3页
第3页 / 共12页
c语言吃数游戏_第4页
第4页 / 共12页
c语言吃数游戏_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《c语言吃数游戏》由会员分享,可在线阅读,更多相关《c语言吃数游戏(12页珍藏版)》请在金锄头文库上搜索。

1、C语言吃数游戏/*路边吃数游戏宫殿中找出几个数之和是7的数并把它们吃掉,再走到7的位置就获胜了。*/#define UP 0x4800#define DOWN 0x5000#define LEFT 0x4b00#define RIGHT 0x4d00#include #include #include int k1724=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0,1,1,

2、1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,3,1,1,1,1,0,1,1,1,4,1,0,1,0,1,1,1,1,1,1,1,0,0,0,1,0,0,1,0,1,0,0,0,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,2,1,1,1,1,6,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,5,1,1,1,0,1,0,0,1,0,0,0,0,0,0,0,

3、0,0,0,1,0,0,0,0,0,0,0,1,0,4,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,1,1,0,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,1,1,1,3,1,1,1,1,1,0,0,0,2,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,

4、1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,;int en(int *b,int n)int i;for(i=0;i20;i+)if(bi=n)return 0;return 1;fu(int *b)int i;for(i=0;i20;i+)bi=0;void lostgame(int num)textcolor(WHITE);gotoxy(11,22);cprintf(The sum of the Numbers you have eaten is: %d.,num);gotoxy

5、(11,23);cprintf(Sorry, you have lost the game!Press any key to restart.);getch();gotoxy(11,22);cprintf( );gotoxy(11,23);cprintf( );void wingame()textcolor(WHITE);gotoxy(11,22);cprintf(Yeah! Congratulations! You have won the game!);gotoxy(11,23);cprintf(Press any key to quit.);getch();window(1,1,25,8

6、0);textbackground(BLACK);textcolor(LIGHTGRAY);clrscr();exit(0);main()int i,j,key,num,b20,p; char ch;aa: window(1,1,25,80);textbackground(LIGHTGREEN);textcolor(YELLOW);clrscr();fu(b);num=0;p=0;textcolor(LIGHTRED);gotoxy(18,1);cprintf(%c(UP) %c(DOWN) %c(LEFT) %c(RIGHT),24,25,27,26);gotoxy(16,2);cprint

7、f(Eat the numbers in your road whose sum is 7,);gotoxy(14,3);cprintf(and eat 7 in the end, then you will win the game!);textcolor(MAGENTA);for(i=4;i21;i+)for(j=20;j44;j+)if(ki-4j-20=0)gotoxy(j,i);cprintf(%c,219);else if(ki-4j-20!=1)gotoxy(j,i);cprintf(%d,ki-4j-20);textcolor(YELLOW);i=5;j=21;gotoxy(j

8、,i);cprintf(1);gotoxy(33,5);cprintf(7);gotoxy(7,7);cprintf(num:%d,num);textcolor(WHITE);gotoxy(11,22);cprintf(Press any key to start game, Q key to quit.);ch=getch();if(ch=Q|ch=q)window(1,1,25,80);textbackground(BLACK);textcolor(LIGHTGRAY);clrscr();exit(0);elsetextcolor(YELLOW);gotoxy(11,22);cprintf

9、( );dokey=bioskey(0);sound(200);delay(1000);nosound();switch(key)case DOWN:if(ki-4+1j-20=0)continue;if(ki-4+1j-20!=1&ki-4+1j-20!=7&en(b,i+j+1)num+=ki-4+1j-20;bp+=i+j+1;gotoxy(7,7);cprintf(num:%d,num);textcolor(YELLOW);gotoxy(j,i+);printf( );gotoxy(j,i);cprintf(1);gotoxy(33,5);if(ki-4j-20=7&num=7)win

10、game();else if(num!=7&ki-4j-20=7)lostgame(num);goto aa;break; case UP:if(ki-4-1j-20=0)continue;if(ki-4-1j-20!=1&ki-4-1j-20!=7&en(b,i+j-1)num+=ki-4-1j-20;bp+=i+j-1;gotoxy(7,7);cprintf(num:%d,num);textcolor(YELLOW);gotoxy(j,i-);printf( );gotoxy(j,i);cprintf(1);gotoxy(33,5);if(ki-4j-20=7&num=7)wingame(

11、);else if(num!=7&ki-4j-20=7)lostgame(num);goto aa;break; case LEFT:if(ki-4j-20-1=0)continue;if(ki-4j-20-1!=1&ki-4j-20-1!=7&en(b,i+j-1)num+=ki-4j-20-1;bp+=i+j-1;gotoxy(7,7);cprintf(num:%d,num);textcolor(YELLOW);gotoxy(j-,i);printf( );gotoxy(j,i);cprintf(1);gotoxy(33,5);if(ki-4j-20=7&num=7)wingame();else if(num!=7&ki-4j-20=7)lostgame(num);goto aa;break; case RIGHT:if(ki-4j-20+1=0)continue;if(ki-4j-20+1!=1&ki-4j-20+1!=7&en(b,i+j+1)num+=ki-4j-20+1;bp+=i+j+1;gotoxy(7,7);cprintf(num:%d,num);textcolor(YELLOW);gotoxy(j+,i);printf( );gotoxy(j,i);cprintf(1);gotoxy(3

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 幼儿/小学教育 > 小学课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号