program received signal sigsegv的解决办法
#include <stdio.h>#define N 1000005
#include <math.h>
int main()
{
int n,m,s1[N],s2[m][2],mid,high,low,i,j,a,b;
scanf("%d",&n);
for(i=0;i<n;i++) scanf("%d",&s1[i]);
scanf("%d",&m);
for(i=0;i<m;i++)
for(j=0;j<2;j++) scanf("%d",&s2[i][j]);//输入两个数组
for(i=0;i<m;i++)
{
for(j=0;j<2;j++)
{
high=n-1;
low=0;
while(high>=low)
{
mid=(low+high)/2;
if(s2[i][j]>s1[mid])
low=mid+1;
else if(s2[i][j]<s1[mid])
high=mid-1;
else
{
if(j==0)a=mid;
if(j==1)b=mid;
printf("%d\n",fabs(a-b));
break;
}
}
}
} //折半查找
return 0;
}
各位大佬,怎么改
debug的结果program received signal sigsegv
编译运行直接结束
[此贴子已经被作者于2018-12-23 12:32编辑过]