The Process Of BFS.
来源:互联网 发布:为什么做seo 编辑:程序博客网 时间:2024/06/05 15:08
//This codes will show u how BFS algorithm works.<pre name="code" class="cpp">#include<iostream>#include<string>#include<list>#include<windows.h>using namespace std;char map[50][50]={" "," "," "," "," "," "," "," "," "," ",};class coordinate{public:int x,y;coordinate(int xx,int yy):x(xx),y(yy){}};void show(){int i,j;for(i=0;i<10;i++){for(j=0;j<20;j++)cout<<map[i][j];cout<<endl;}Sleep(100);//flash time if u wanne see faster ,erase it.system("cls");}int main(){list<coordinate>queue;int visited[100][100]={0},start_x,start_y,next_x,next_y,row,col,dir,direction[4][2]={{-1,0},{0,-1},{1,0},{0,1}};cout<<"Input the start coordinate which x range from 0 to 10 and y range 0 to 20(eg intput: 5 2)"<<endl;cin>>start_x>>start_y;row=10;col=20;visited[start_x][start_y]=1;map[start_x][start_y]='*';queue.push_back(coordinate(start_x,start_y));while(!queue.empty()){for(dir=0;dir<=3;dir++){next_x=queue.front().x+direction[dir][0];next_y=queue.front().y+direction[dir][1];if(next_x<0||next_y<0||next_x>=row||next_y>=col)continue;else if(visited[next_x][next_y]==0){show();map[next_x][next_y]='*';visited[next_x][next_y]=1;queue.push_back(coordinate(next_x,next_y));show();}}queue.pop_front();}return 0;}
0 0
- The Process Of BFS.
- The process of testing
- The Process Of PCI
- The Process of Software Architecting
- The configuration process of NFS...
- The compilation process of C
- the verify process of keystone
- Trace the process of the start of Linux
- The whole process of developing software.
- Java-The full process of initialization
- Management of the Object-oriented Development Process
- Management of the Object-Oriented Development Process
- The logical process of account assignment determination
- In the process of studying J2ee!!!
- Major Problem in the Process of Urbanization
- the process of developing a program
- Makefile and the process of Make
- Analyse the Booting process of Linux Kernel
- Java核心技术——编程环境
- 实用JS系列——BOM常用对象
- 18个最热深度学习Github项目逐一介绍
- cmd后门
- Have a look at what’
- The Process Of BFS.
- 【大话设计模式】——行为型模式之“拟人化模式”
- 课程设计
- POJ 3692-Kindergarten(二分图_最小顶点集)
- pip的安装以及在安装的过程中遇到的问题及解决方法
- php图片上传之文件安全
- 求两个数的最大公约公倍数
- Android禁止锁屏
- SQLserver 删除数据库日志SQL