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 |
为什么会Runtime Error?#include <iostream> using namespace std; void check(char**p,int,int); int main() { int N,M; cin>>M>>N; char**p=new char*[N]; for (int i=0;i<N;i++) p[i]=new char[M]; for (int j=0;j<N+2;j++) { p[0][j]='.'; p[M+1][j]='.'; } for (int i=1;i<M+1;i++) { p[i][0]='.'; p[i][N+1]='.'; } for (int i=1;i<=M;i++) for (int j=1;j<=N;j++) cin>>p[i][j]; int counter=0; for(int i=1;i<=M;i++) for(int j=1;j<=N;j++) if(p[i][j]=='W') { counter++; p[i][j]=1; check(p,i,j); } cout<<counter<<endl; for (int i=0;i<N;i++) delete[] p[i]; delete[] p; return 0; } void check(char**p,int hang,int lie) { bool flag=true; while(flag) { flag=false; if (p[hang-1][lie+1]=='W') { flag=true; p[hang-1][lie+1]=1; check(p,hang-1,lie+1); } for(int i=hang;i<=hang+1;i++) for(int j=lie-1;j<=lie+1;j++) { if(p[i][j]=='W') { flag=true; p[i][j]=1; check(p,i,j); } } } if(flag==false) return; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator