| ||||||||||
| 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 | |||||||||
怎么错了#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator