Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

拜托大神帮我除错一下 感恩~~

Posted by jchen8tw at 2015-10-01 20:57:24 on Problem 2386
#define max_n 100
#define max_m 100
#include<stdio.h>
char map[max_n][max_m+1];
int n,m;

void dfs(int nx,int ny){
	map[nx][ny] = '.';
	for(int dx = -1;dx <= 1;dx++)
		for(int dy = -1;dy <= 1;dy++){
			int nex = nx+dx, ney = ny+dy;
			if(nex>=0 && nex <m && ney>=0 && ney < n && map[nex][ney] == 'W'){
				dfs(nex,ney);
			}
		}
	return;
}
int main(){
	int cnt = 0;
	scanf("%d%d",&n,&m);
	for(int i = 0;i<n;i++)
			scanf("%s",&map[i]);
			
	for(int i = 0;i<n;i++)
		for(int j = 0;j<m;j++){
			if(map[j][i] == 'W'){
				dfs(j,i);
				cnt++;
			}
		}
	printf("%d\n",cnt);
} 

范例测资都有过啊~~~

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator