hdu 1312 Red and Black
来源:互联网 发布:苹果远程抹掉数据恢复 编辑:程序博客网 时间:2024/05/23 01:14
h是行,w是列
#include <iostream>#include <stdio.h>#include <string>using namespace std;char a[25][25];int w,h,z=1;int k[4][2]={{-1,0},{0,-1},{0,1},{1,0}};void f(int x,int y){ int i,xx,yy; a[x][y]='#';//走过的设为墙 for(i=0;i<4;i++) { xx=x+k[i][0];//得出下一个坐标 yy=y+k[i][1]; if(xx<0||xx>=h||yy<0||yy>=w) continue; if(a[xx][yy]=='.') { z++;//条件成立步数加一 f(xx,yy);//递归,继续搜索 } }}int main(){ int i,j; while(scanf("%d%d",&w,&h)!=EOF) { z=1; getchar(); if(w==0||h==0) break; for(i=0;i<h;i++) { scanf("%s",&a[i]); } for(i=0;i<h;i++) { for(j=0;j<w;j++) { if(a[i][j]=='@') { f(i,j); } } } printf("%d\n",z); } return 0;}
0 0
- Red and Black hdu 1312
- HDU 1312 Red and Black
- HDU 1312 Red and Black
- hdu 1312 Red and Black
- Hdu 1312 - Red and Black
- hdu-1312-Red and Black
- hdu 1312Red and Black
- hdu 1312 Red and Black
- hdu - 1312 - Red and Black
- hdu 1312 Red and Black
- hdu 1312 Red and Black
- HDU-1312(red and black)
- HDU 1312 Red and Black
- hdu 1312 Red and Black
- HDU 1312 Red and Black
- hdu 1312 Red and Black
- hdu 1312 Red and Black
- hdu 1312 Red and Black
- NoSQL系列:选择合适的数据库
- Android——PopupWindow(泡泡)初体验
- 【暑假测试2】D ACdream 1125 ACfun-字典序(水)
- Leetcode135(Candy)
- RESTful
- hdu 1312 Red and Black
- C语言程序 指针
- HDU N!
- Android--Application
- UE.getEditor is not a function
- Extjs 蒙板效果实现
- Android自定义View之自定义“更多”界面
- emmet插件的使用方法(高速打代码)
- Eclipse快捷键与使用技巧总结