| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:求改错= =,到底哪里错了我,我的逻辑有问题吗,怎么都不对呢In Reply To:求改错= =,到底哪里错了我,我的逻辑有问题吗,怎么都不对呢 Posted by:Saleed at 2016-07-29 21:44:01 > //POJ 2386 lake counting
>
> #include<iostream>
> using namespace std;
> char field[200][200];
> int dfs(int i,int j);
> int row,col;
> int main(){
> cin>>row>>col;
> for(int i=0;i<row;i++){
> for(int j=0;j<col;j++){
> cin>>field[i][j];
> }
> }
> int time=0;
> for(int i=0;i<row;i++){
> for(int j=0;j<col;j++){
> if(dfs(i,j)) time++;
> }
> }
> cout<<time<<endl;
>
> }
> int dfs(int i,int j){
> if(field[i][j]=='W'){
> field[i][j]='.';
> for(int dx=-1;dx<=1;dx++){
> for(int dy=-1;dy<=1;dy++){
> if(i+dx>=0&&i+dx<col&&j+dy>=0&&j+dy<row) dfs(i+dx,j+dy);
> }
> }
> return 1;
> }
> else return 0;
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator