资源描述:
《c语言吃数游戏.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、C语言吃数游戏/*路边吃数游戏宫殿中找出几个数之和是7的数并把它们吃掉,再走到7的位置就获胜了。*/#defineUP0x4800#defineDOWN0x5000#defineLEFT0x4b00#defineRIGHT0x4d00#include#include#includeintk[17][24]={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,
2、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,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,
3、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,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,
4、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,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,};inten(int*b,intn){inti;f
5、or(i=0;i<20;i++)if(b[i]==n)return0;return1;}fu(int*b){inti;for(i=0;i<20;i++)b[i]=0;}voidlostgame(intnum){textcolor(WHITE);gotoxy(11,22);cprintf("ThesumoftheNumbersyouhaveeatenis:%d.",num);gotoxy(11,23);cprintf("Sorry,youhavelostthegame!Pressanykeytorestart
6、...");getch();gotoxy(11,22);cprintf("");gotoxy(11,23);cprintf("");}voidwingame(){textcolor(WHITE);gotoxy(11,22);cprintf("Yeah!Congratulations!Youhavewonthegame!");gotoxy(11,23);cprintf("Pressanykeytoquit...");getch();window(1,1,25,80);textbackground(BLACK)
7、;textcolor(LIGHTGRAY);clrscr();exit(0);}main(){inti,j,key,num,b[20],p;charch;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);
8、gotoxy(16,2);cprintf("Eatthenumbersinyourroadwhosesumis7,");gotoxy(14,3);cprintf("andeat7intheend,thenyouwillwinthegame!");textcolor(MAGENTA);for(i=4;i<21;i++)for(j=20;j<44;j++)if(k[i-4][j-20]==0){gotoxy(j,i)