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

Re:到底是哪里错了???试了好几次,真的不会改了!!求教大神,感激不尽

Posted by Lishuhao at 2015-04-20 14:02:28 on Problem 2386
In Reply To:到底是哪里错了???试了好几次,真的不会改了!!求教大神,感激不尽 Posted by:Alcatraz at 2015-04-12 01:50:48
> #include<stdio.h>
> int n,m;
> char k[101][101];
> void change(int x,int y)
> {
> 	int dx,dy,nx,ny;
> 	for(dx=-1;dx<=1;dx++)
> 	{
> 		for(dy=-1;dy<=1;dy++)
> 		{
> 			nx=x+dx;
> 			ny=y+dy;
> 			if(nx>=0&&nx<n&&ny>=0&&ny<m&&k[nx][ny]=='W')
> 			{
> 				change(nx,ny);
> 			}
> 		}
> 	}
> }
> int main()
> {
>     //void change(int x,int y);
> 	int i,j,s;
>     int n,m;
>     char k[101][101];
> 	scanf("%d%d",&n,&m);
> 	for(i=0;i<n;i++)
> 	{
> 			scanf("%s",k[i]);
> 	}
> 	s=0;
> 	for(i=0;i<n;i++)
> 	{
> 		for(j=0;j<m;j++)
> 		{
> 			if(k[i][j]=='W')
> 			{
> 				s++;
> 				change(i,j);
> 			}
> 		}
> 	}
> 	printf("%d\n",s);
> 	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