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; char maze[50][50][50]; struct location { int x; int y; int z; }now[40000],next[40000]; int main() { for(int i=0;i<50;i++) for(int j=0;j<50;j++) for(int k=0;k<50;k++) maze[i][j][k]='#'; int level,row,column; int min=30000; char input[49]={0}; while(1) { cin>>level>>row>>column; cin.get(); if(level==0&&row==0&&column==0) break; for(int i=0;i<30000;i++) { now[i].x=now[i].y=now[i].z=0; next[i].x=next[i].y=next[i].z=0; } min=30000; for(int i=0;i<50;i++) for(int j=0;j<50;j++) for(int k=0;k<50;k++) maze[i][j][k]='#'; location start,end; int count=-1; for(int i=1;i<=level;i++) { for(int j=1;j<=row;j++) { cin.getline(input,49); for(int k=1;k<=column;k++) { maze[i][j][k]=input[k-1]; if(maze[i][j][k]=='S') { start.x=i; start.y=j; start.z=k; } else if(maze[i][j][k]=='E') { end.x=i; end.y=j; end.z=k; } } } if(i<level) cin.get(); } now[0]=start; int nexti=1; while(nexti!=0) { nexti=0; count++; for(int i=0;now[i].x!=0&&i<30000;i++) { if(now[i].x==end.x&&now[i].y==end.y&&now[i].z==end.z) { min=count; break; } maze[now[i].x][now[i].y][now[i].z]='#'; if(maze[now[i].x+1][now[i].y][now[i].z]!='#') { next[nexti]=now[i]; next[nexti].x++; nexti++; } if(maze[now[i].x-1][now[i].y][now[i].z]!='#') { next[nexti]=now[i]; next[nexti].x--; nexti++; } if(maze[now[i].x][now[i].y+1][now[i].z]!='#') { next[nexti]=now[i]; next[nexti].y++; nexti++; } if(maze[now[i].x][now[i].y-1][now[i].z]!='#') { next[nexti]=now[i]; next[nexti].y--; nexti++; } if(maze[now[i].x][now[i].y][now[i].z+1]!='#') { next[nexti]=now[i]; next[nexti].z++; nexti++; } if(maze[now[i].x][now[i].y][now[i].z-1]!='#') { next[nexti]=now[i]; next[nexti].z--; nexti++; } } if(nexti==0&&min>=3000) { min=0; break; } for(int i=0;i<30000;i++) { now[i]=next[i]; next[i].x=next[i].y=next[i].z=0; } } if(min==0) cout<<"Trapped!"<<endl; else cout<<"Escaped in "<<min<<" minute(s)."<<endl; cin.get(); } return 0; } 谢谢!! Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator