| ||||||||||
| 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 | |||||||||
为什么我的程序在编译器里一运行就出现Abnormal program termination啊?同题
提交的时候显示的是Compile Error.
源程序如下:
#include<stdio.h>
int a[100][100],res[100][100];
int m,n,max=0;
int t[100][100];
void doit(int y,int x)
{
res[y][x]=0;
if(x>0&&a[y][x-1]<a[y][x])
{
if(t[y][x-1]==0)
doit(y,x-1);
res[y][x]=res[y][x-1];
}
if(x<(n-1)&&a[y][x+1]<a[y][x])
{
if(t[y][x+1]==0)
doit(y,x+1);
res[y][x]=res[y][x+1];
}
if(y>0&&a[y-1][x]<a[y][x])
{
if(t[y-1][x]==0)
doit(y-1,x);
res[y][x]=res[y][x-1];
}
if(y<(m-1)&&a[y+1][x]<a[y][x])
{
if(t[y+1][x]==0)
doit(y+1,x);
res[y][x]=res[y][x+1];
}
if(max<res[y][x])
max=res[y][x];
t[y][x]=1;
}
void main()
{
int i,j;
clrscr();
scanf("%d%d",&m,&n);
for(i=0;i<m;i++)
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
t[i][j]=0;
}
for(i=0;i<m;i++)
for(j=0;j<n;j++)
{
if(t[i][j]==0)
doit(i,j);
}
printf("%d",max);
}
感觉上是最后一句printf()有问题,因为如果不加这句就能编译过(当然没有任何输出),一加上这句就只显示Abnormal program termination
然后发现不管在什么地方写任何输出语句都会有问题,比如改成printf("%d",i);都会出现同样的显示。
这是为什么啊?
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator