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

请输入时nm时中间加上空格,真的,,很坑,,,,真的,,我要制造病毒黑了它系统

Posted by cocoasong at 2016-07-20 16:28:30 on Problem 2386
#include<stdio.h>
#include<iostream>
using namespace std;
const int N = 1000; 
char a[N][N]; 
int n, m; 
void dfs(int i, int j)
{
	a[i][j] = '.';
	int x, y, x1, y1;
	for(x = -1; x<=1; x++)
	{
		for(y = -1; y<=1; y++)
		{
			x1 = i+x; y1 = j+y;
			if(x1 >= 0 && x1 <n && y1 < m && 0<= y1 && a[x1][y1] == 'W')
			dfs(x1, y1); 	
		} 
	} 
	                                                                                                                    
} 
int main()
{
	int i, j, ans = 0; 
	scanf("%d %d", &n, &m); 
	for(i = 0; i<n; i++)
	{
		scanf("%s", a[i]); //输入请输入%s, %c有问题
	} 
	for(i = 0; i<n; i++)
	{
		for(j = 0; j<m; j++)
		{
			 if(a[i][j] == 'W')
			 {
			 	dfs(i, j);
				 ans++; 
			 } 
		 
		}  
	}
	printf("%d\n", ans);  
	return 0; 
} 

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