Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

runtime error,这是怎么了

Posted by 416458882 at 2008-05-03 18:38:16 on Problem 1088
#include<stdio.h>
#define M 100
int a[M][M];
int b[M][M];
int g[4]={0,1,-1,0};
int h[4]={1,0,0,-1};
int max=0;
int m=0;
int row=0;
int col=0;
int j=0;

void bb(int o,int x,int y);
int main(void)
{  int i; 
	int p,q;
 scanf("%d%d",&row,&col);
 printf("\n");
 for(i=0;i<row;i++)
 {
  for(j=0;j<col;j++)
  {   
   int k;
   scanf("%d",&k);
   a[i][j]=k;
   b[i][j]=0;
   if(k>max)
   {
    max=k;
    p=i;
	q=j;
   }
  }
 }
 bb(1,p,q);
 for(i=0;i<row;i++)
 {
  for(j=0;j<col;j++)
  {
   if(b[i][j]==0)
   bb(1,i,j);
  }
 }
 printf("\n%d\n",m);
 return 0;
}

void bb(int o,int x,int y)
{int i;
 b[x][y]=1;
 if(o>m)
 {
  m=o;
 }

 for(i=0;i<4;i++)
 {
  if((x+g[i]<row)&&(y+h[i]<col)&&(x+g[i]>=0)&&(y+h[i]>=0)&&(a[x+g[i]][y+h[i]]<=a[x][y]))
  {
	  bb(o+1,x+g[i],y+h[i]);
  }
 }
}
 
 
 
			

	 

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator