标签:\n one hid display alt == char argc include
#include<iostream> using namespace std; int migo[7][7]={ {2, 2, 2, 2, 2, 2, 2}, {2, 0, 0, 0, 0, 0, 2}, {2, 0, 2, 0, 2, 0, 2}, {2, 0, 0, 0, 0, 2, 2}, {2, 2, 0, 2, 0, 2, 2}, {2, 0, 0, 0, 0, 0, 2}, {2, 2, 2, 2, 2, 2, 2}};//迷宫图 int startX=1,startY=1; int endX=5,endY=5; int flag=0; int find(int x,int y) { migo[x][y]=1; if(x==endX&&y==endY) flag=1; if(migo[x][y+1]==0&&flag!=1) find(x,y+1); if(migo[x][y-1]==0&&flag!=1) find(x,y-1); if(migo[x+1][y]==0&&flag!=1) find(x+1,y); if(migo[x-1][y]==0&&flag!=1) find(x-1,y); if(flag!=1) migo[x][y]=0; return flag; }
int main(int argc, char **argv) { int i,j; printf("显示迷宫:\n"); for(i=0;i<7;i++) { for(j=0;j<7;j++) if(migo[i][j]==2) printf("█"); else printf(" "); printf("\n"); } if(find(startX,startY)==0) { printf("\n没有找到出口!\n"); } else { printf("\n显示路径:\n"); for(i=0;i<7;i++) { for(j=0;j<7;j++) { if(migo[i][j]==2) printf("█"); else if(migo[i][j]==1) printf("*"); else printf(" "); } printf("\n"); } } return 0; }
标签:\n one hid display alt == char argc include
原文地址:https://www.cnblogs.com/helloworld2019/p/10353957.html