标签:dex col span 没有 处理 IV sea font 判断
int Search(int* arr,int x,int y,int num)
{
//把二维数组当做一维数组处理
if(arr == NULL || x <= 0 || y<= 0) return -1;
int a = x-1;
int b = 0;
while(a >= 0 && a < x && b >=0 && b < y)
{
if(arr[a*y+b] > num)
{
a--;
}
else if(arr[a*y+b] < num)
{
b++;
}
else
return 1;
}
return -1;
}
int main()
{
int arr[5][5] = {1,55,79,82,88,
2,56,80,83,109,
3,57,81,84,110,
4,58,90,100,120,
5,59,99,111,122};
int index = 0;
index = Search((int*)arr,5,5,89);
printf("%d",index);
return 0;
}
标签:dex col span 没有 处理 IV sea font 判断
原文地址:https://www.cnblogs.com/TheQi/p/9126299.html