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 hxl at 2005-08-01 19:16:42 on Problem 2386
#include<iostream>
#include<string>
using namespace std;
int  bs();
bool u[100][100];
void slov(int x,int y);
int dx[8]={-1,-1,-1,0,0,1,1,1};
int dy[8]={1,0,-1,1,-1,1,0,-1};
char a[101][101];
int qx[20000];
int qy[20000];
int m,n;
void main()
{int i;
//freopen("25.txt","r",stdin);
cin>>n>>m;
for(i=0;i<n;i++)
cin>>a[i];
bs();
}
 int bs()
 {int i,j,k=0;
  for(i=0;i<n;i++)
	 for(j=0;j<m;j++)
        if(a[i][j]=='W')
	 {
			for (int p=0;p<n;p++)
				cout<<a[p]<<endl;
			cout<<endl;

		 k++;
	 slov(i,j);
	 }

	 cout<<k<<endl;
	 for(i=0;i<n;i++)
	 {for(j=0;j<m;j++)
		 cout<<a[i][j];
	 cout<<endl;}
	 return 0;
 }
 void slov(int x,int y)
 {	
	 int t,tail=0,head=1;
     qx[0]=x;
    qy[0]=y;
	a[x][y]='.';
	while(tail<head)
	{
		x=qx[tail]; y=qy[tail];++tail;
	 for(t=0;t<8;t++)
	 if(x+dx[t]>=0&&x+dx[t]<n&&y+dx[t]>=0&&y+dy[t]<m&&a[x+dx[t]][y+dy[t]]=='W')
	{
		 
		a[x+dx[t]][y+dy[t]]='.';
	 qx[head]=x+dx[t];
	qy[head]=y+dy[t];
	head++;
	 }
	}
 }

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