c语言编程游戏代码大全_c语言编程游戏代码-热头条
来源:互联网     时间:2023-06-24 04:59:35


【资料图】

1、#includeint grid[14][17]={ {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {0,0,1,0,0,0,1,1,0,0,0,1,1,1,1,1,1}, {1,1,0,0,0,1,1,0,1,1,1,0,0,1,1,1,1}, {1,0,1,1,0,0,0,0,1,1,1,1,0,0,1,1,1}, {1,1,1,0,1,1,1,1,0,1,1,0,1,1,0,0,1}, {1,1,1,0,1,0,0,1,0,1,1,1,1,1,1,1,1}, {1,0,0,1,1,0,1,1,1,0,1,0,0,1,0,1,1}, {1,0,0,1,1,0,1,1,1,0,1,0,0,1,0,1,1}, {1,0,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1}, {1,0,0,1,1,0,1,1,0,1,1,1,1,1,0,1,1}, {1,1,1,0,0,0,1,1,0,1,1,0,0,0,0,0,1}, {1,0,0,1,1,1,1,1,0,0,0,1,1,1,1,0,1}, {1,0,1,0,0,1,1,1,1,1,0,1,1,1,1,0,0}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1} }; void deal(int x,int y) { if(grid[x-1][y+1]>grid[x][y]+1||grid[x-1][y+1]==-1) { grid[x-1][y+1]=grid[x][y]+1; deal(x-1,y+1); } if(grid[x][y+1]>grid[x][y]+1||grid[x][y+1]==-1) { grid[x][y+1]=grid[x][y]+1; deal(x,y+1); } if(grid[x+1][y+1]>grid[x][y]+1||grid[x+1][y+1]==-1) { grid[x+1][y+1]=grid[x][y]+1; deal(x+1,y+1); } if(grid[x+1][y]>grid[x][y]+1||grid[x+1][y]==-1) { grid[x+1][y]=grid[x][y]+1; deal(x+1,y); } if(grid[x+1][y-1]>grid[x][y]+1||grid[x+1][y-1]==-1) { grid[x+1][y-1]=grid[x][y]+1; deal(x+1,y-1); } if(grid[x][y-1]>grid[x][y]+1||grid[x][y-1]==-1) { grid[x][y-1]=grid[x][y]+1; deal(x,y-1); } if(grid[x-1][y-1]>grid[x][y]+1||grid[x-1][y-1]==-1) { grid[x-1][y-1]=grid[x][y]+1; deal(x-1,y-1); } if(grid[x-1][y]>grid[x][y]+1||grid[x-1][y]==-1) { grid[x-1][y]=grid[x][y]+1; deal(x-1,y); } return; } void main() { //int x1,x2,y1,y2; int i,j; for(i=0;i<14;i++) for(j=0;j<17;j++) { if(grid[i][j]==1) grid[i][j]=0; else grid[i][j]=-1; } grid[1][0]=1; deal(1,0); grid[1][0]=1; for(i=0;i<14;i++) { for(j=0;j<17;j++) { cout<

本文就为大家分享到这里,希望小伙伴们会喜欢。

标签: