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在vc6.0里运行正确#include<iostream.h> int Max=0; #define MAX 10000 struct node { int i; int j; int qz; int h; node * sp; node *zp; node *yp; node *xp; }; struct px1 { int h; int i; int j; }; void px(px1 node[],int low,int high); int main(void) { int row,col,i,j; node *mon; px1 *temp; cin>>row>>col; mon=new node [row*col+1]; temp=new px1 [row*col+1]; for(i=0;i<row;i++) for(j=1;j<(col+1);j++) { temp[i*col+j].i=mon[i*col+j].i=i+1; temp[i*col+j].j=mon[i*col+j].j=j; cin>>mon[i*col+j].h; mon[i*col+j].qz=0; temp[i*col+j].h=mon[i*col+j].h; if(i==0) mon[i*col+j].sp=NULL; else mon[i*col+j].sp=&mon[(i-1)*col+j]; if(i==(row-1)) mon[i*col+j].xp=NULL; else mon[i*col+j].xp=&mon[(i+1)*col+j]; if(j==0) mon[i*col+j].zp=NULL; else mon[i*col+j].zp=&mon[i*col+j-1]; if(j==col) mon[i*col+j].yp=NULL; else mon[i*col+j].yp=&mon[i*col+j+1]; } px(temp,1,row*col); for(i=1;i<=row*col;i++) { int tz=1;//可能是这段代码的问题请高手帮忙仔细看看 if(mon[(temp[i].i-1)*col+temp[i].j].sp!=NULL&&mon[(temp[i].i-1)*col+temp[i].j].sp->h<mon[(temp[i].i-1)*col+temp[i].j].h) tz=mon[(temp[i].i-1)*row+temp[i].j].sp->qz+1; if(mon[(temp[i].i-1)*col+temp[i].j].zp!=NULL&&mon[(temp[i].i-1)*col+temp[i].j].zp->h<mon[(temp[i].i-1)*col+temp[i].j].h) { if(mon[(temp[i].i-1)*col+temp[i].j].zp->qz>tz-1) tz=mon[(temp[i].i-1)*col+temp[i].j].zp->qz+1; } if(mon[(temp[i].i-1)*col+temp[i].j].yp!=NULL&&mon[(temp[i].i-1)*col+temp[i].j].yp->h<mon[(temp[i].i-1)*col+temp[i].j].h) { if(mon[(temp[i].i-1)*col+temp[i].j].yp->qz>tz-1) tz=mon[(temp[i].i-1)*col+temp[i].j].yp->qz+1; } if(mon[(temp[i].i-1)*col+temp[i].j].xp!=NULL&&mon[(temp[i].i-1)*col+temp[i].j].xp->h<mon[(temp[i].i-1)*col+temp[i].j].h) { if(mon[(temp[i].i-1)*col+temp[i].j].xp->qz>tz-1) tz=mon[(temp[i].i-1)*col+temp[i].j].xp->qz+1; } mon[(temp[i].i-1)*col+temp[i].j].qz=tz; if(mon[(temp[i].i-1)*col+temp[i].j].qz>Max) Max=mon[(temp[i].i-1)*col+temp[i].j].qz; } cout<<Max<<endl; return 0; } void px(px1 node[],int low,int high) { int i,j; px1 pivot; if(low<high) { pivot = node[low]; i=low; j=high; while(i<j) { while(i<j&&node[j].h>=pivot.h) j=j-1; if(i<j) { node[i]=node[j]; i=i+1; } while(i<j&&node[i].h<=pivot.h) i=i+1; if(i<j) { node[j]=node[i]; j=j-1; } } node[i]=pivot; px(node,low,i-1); px(node,i+1,high); } // return; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator