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是因为什么提交后显示runtime error,在本地运行很好。 以下是我的代码,求大神帮忙解答一下为什么会有runtime error #include<iostream> using namespace std; int maze[5][5]; struct node{ int x; int y; int pre; }qu[100]; int front=0; int rear=1; int orx[4]={0,0,1,-1}; int ory[4]={1,-1,0,0}; void Prt(int i){ if(qu[i].pre!=-1){ Prt(qu[i].pre); cout<<"("<<qu[i].x<<","<<qu[i].y<<")"<<endl; } else cout<<"("<<qu[i].x<<","<<qu[i].y<<")"<<endl; } void sr_h(int x,int y){ qu[front].x=x; qu[front].y=y; qu[front].pre=-1; while(front<rear){ bool you=false; for(int i=0;i<4;i++){ int mx=qu[front].x+orx[i]; int my=qu[front].y+ory[i]; if(mx<0||mx>4||my<0||my>4||maze[mx][my]){ continue; } qu[rear].x=mx; qu[rear].y=my; qu[rear].pre=front; rear++; if(mx==4&&my==4){ Prt(rear-1); you=true; break; } } if(you)break; front++; } } int main(){ for(int i=0;i<5;i++){ for(int j=0;j<5;j++){ cin>>maze[i][j]; } } sr_h(0,0); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator