当前位置: 代码迷 >> C语言 >> 迫不得已!
  详细解决方案

迫不得已!

热度:296   发布时间:2005-12-27 20:38:00.0
迫不得已!

小弟实在是迫不得已,各位大哥帮忙找找TC的扫雷程序吧!小弟万分感谢!

搜索更多相关的解决方案: 迫不得已  

----------------解决方案--------------------------------------------------------

!网上都找不到吗?


----------------解决方案--------------------------------------------------------
你试试能不能运行吧!~!~!~
#include<stdio.h>
#include<graphics.h>
#include<stdlib.h>
struct list
{
int x;
int y;
int num;
int bomb;
int wa;
};
struct list di[10][10];
int currentx=210;
int currenty=130;
void initxy(void)
{
int i,j;
for(i=0;i<=9;i++)
for(j=0;j<=9;j++)
{
di[j].x=i*20+200;
di[j].y=j*20+120;
di[j].wa=0;
di[j].bomb=0;
}
}




void initmu(void)
{
int i,j;
setcolor(2);
rectangle(200,120,400,320);
rectangle(190,110,410,330);
setfillstyle(8,14);
floodfill(191,111,2);
for(i=0;i<=9;i++)
for(j=0;j<=9;j++)
rectangle(di[j].x,di[j].y,di[j].x+19,di[j].y+19);
outtextxy(450,200,"press 'enter' to kick");
outtextxy(450,250,"press '\\' to mark");
}

void randbomb(void)
{
int k;
int i,j;
randomize();
for(i=0;i<=9;i++)
for(j=0;j<=9;j++)
{
k=random(5);
if(k==2)
di[j].bomb=1;

}
}

void jisuan(void)
{
int k=0;
int i,j;
for(i=0;i<=9;i++)
for(j=0;j<=9;j++)
{
if(i&&j&&di[i-1][j-1].bomb)
k=k+1;
if(i&&di[i-1][j].bomb)
k=k+1;
if(j&&di[j-1].bomb)
k=k+1;
if(i<=8&&di[i+1][j].bomb)
k=k+1;
if(j<=8&&di[j+1].bomb)
k=k+1;
if(i<=8&&j<=8&&di[i+1][j+1].bomb)
k=k+1;
if(i&&j<=8&&di[i-1][j+1].bomb)
k=k+1;
if(i<=8&&j&&di[i+1][j-1].bomb)
k=k+1;
di[j].num=k;
k=0;
}
}


void xianbomb(void)
{
int i,j;
char biaoji[2];
char znum[2];
biaoji[0]=1;
biaoji[1]=NULL;
for(i=0;i<=9;i++)
for(j=0;j<=9;j++)
{
if(di[j].bomb==1)
outtextxy(di[j].x+2,di[j].y+2,biaoji);
else
{
itoa(di[j].num,znum,10);
setfillstyle(1,0);
bar(i*20+202,j*20+122,i*20+218,j*20+138);
outtextxy(i*20+202,j*20+122,znum);
}
}
}
void move(void)
{
int key;
key=bioskey(1);
if(key)
key=bioskey(0);

if(key==0x4800)
{
if(currenty>130)
{
setcolor(0);
circle(currentx,currenty,5);
currenty-=20;
setcolor(4);
circle(currentx,currenty,5);
}
else
{
setcolor(0);
circle(currentx,currenty,5);
currenty=310;
setcolor(4);
circle(currentx,currenty,5);
}
}
if(key==0x4b00)
{
if(currentx>210)
{
setcolor(0);
circle(currentx,currenty,5);
currentx-=20;
setcolor(4);
circle(currentx,currenty,5);
}
else
{
setcolor(0);
circle(currentx,currenty,5);
currentx=390;
setcolor(4);
circle(currentx,currenty,5);
}
}
if(key==0x4d00)
{
if(currentx<390)
{
setcolor(0);
circle(currentx,currenty,5);
currentx+=20;
setcolor(4);
circle(currentx,currenty,5);
}
else
{
setcolor(0);
circle(currentx,currenty,5);
currentx=210;
setcolor(4);
circle(currentx,currenty,5);
}
}
if(key==0x5000)
{
if(currenty<310)
{
setcolor(0);
circle(currentx,currenty,5);
currenty+=20;
setcolor(4);
circle(currentx,currenty,5);
}
else
{
setcolor(0);
circle(currentx,currenty,5);
currenty=130;
setcolor(4);
circle(currentx,currenty,5);
}
}
if(key==0x1c0d)
{
int i,j;
char snum[2];
snum[0]=NULL;
snum[1]=NULL;
i=(currentx-210)/20;
j=(currenty-130)/20;
if(di[j].bomb==1)
{
outtextxy(100,100,"game over");
xianbomb();
sleep(2);
exit(0);
}
if(di[j].bomb==0)
{
di[j].wa=1;
setfillstyle(1,0);
bar(currentx-8,currenty-8,currentx+8,currenty+8);
setcolor(15);
itoa(di[j].num,snum,10);
outtextxy(currentx-8,currenty-8,snum);
setcolor(4);
circle(currentx,currenty,5);
}
}
if(key==0x2b5c)
{
char biaoji[2];
biaoji[0]=1;
biaoji[1]=NULL;
setcolor(0);
bar(currentx-8,currenty-8,currentx+8,currenty+8);
setcolor(4);
outtextxy(currentx-8,currenty-8,biaoji);
circle(currentx,currenty,5);
}
}

void success(void)
{
int k=1;
int i,j;
for(i=0;i<=9;i++)
for(j=0;j<=9;j++)
if(di[j].bomb==0&&di[j].wa==0)
k=0;
if(k==1)
{
outtextxy(100,100,"success good");
xianbomb();
sleep(2);
exit(0);

}
}

void main(void)
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"");
initxy();
initmu();
randbomb();
jisuan();
setcolor(4);
circle(210,130,5);
while(1)
{
move();
success();
}
}

----------------解决方案--------------------------------------------------------

有错!!


----------------解决方案--------------------------------------------------------
恩,好象不能运行哟,这么长看也看不懂
----------------解决方案--------------------------------------------------------
  相关解决方案