poj1979广搜c语言
来源:互联网 发布:php函数list 编辑:程序博客网 时间:2024/05/10 00:14
坑了,写程序的时候倒数第二个花括号把return 0;给我括起来了,程序一次就结束了,吃了饭回来才顿悟了
#include<stdio.h>struct point{int hang,lie;int predecessor;}queue[402],p,visit_point;char brr[30][30],c;int head=0,tail=0,n,m;void enqueue(struct point p){ queue[tail++] = p;}struct point dequeue(void){ return queue[head++];}void visit(int hang, int lie){ visit_point.hang=hang;visit_point.lie=lie;visit_point.predecessor=head-1; brr[hang][lie] = '#'; enqueue(visit_point);}int main(){int i,j;while(1){ scanf("%d%d",&n,&m); if(m==0&&n==0) break;scanf("%c",&c);for(i=0;i<m;i++)for(j=0;j<=n;j++){scanf("%c",&brr[i][j]);if(brr[i][j]=='@'){p.hang=i;p.lie=j;p.predecessor=1;}} queue[0]=p;tail++;while(tail!=head) { p = dequeue(); if (p.lie+1 < n && brr[p.hang][p.lie+1] == '.') visit(p.hang, p.lie+1); if (p.hang+1 < m && brr[p.hang+1][p.lie] == '.') visit(p.hang+1, p.lie); if (p.lie-1 >= 0 && brr[p.hang][p.lie-1] == '.') visit(p.hang, p.lie-1); if (p.hang-1 >= 0&& brr[p.hang-1][p.lie] == '.') visit(p.hang-1, p.lie); } printf("%d\n",tail); head=0;tail=0;}return 0;}
0 0
- poj1979广搜c语言
- poj3984广搜c语言
- C语言 跳马 队列,广搜,结构体
- C语言 六数码 队列,广搜,map函数
- C语言 木乃伊迷宫 队列,广搜,map函数
- POJ1979(经典深搜)
- POJ1979
- poj1979
- POJ1979
- POJ1979
- poj1979
- poj1979
- poj1979
- poj1979
- poj1979
- poj1979
- poj1979
- 【POJ1979】
- Leetcode#56||Merger Intervals
- gdb 多线程调试
- Android根据反射获取R文件中的字段值即id值
- (7) <IED> eclipse-3.6.1-64安装反编译插件 JD_Eclipse插件
- c++设计模式
- poj1979广搜c语言
- Uva12880(二分匹配)
- java泛型的内部原理:类型擦除以及类型擦除带来的问题
- 最小费用最大流,SPFA
- 十步图解CSS的position
- HTML 列表
- 【bzoj1191】 HNOI2006超级英雄Hero 二分图匹配
- android开源框架
- fir.im Weekly - 工欲善其事,必先利其器