#include<stdio.h>
//2 3 4
//
//5 6 7
//
//8 9 10
int FindNum(int arr[3][3], int k, int row, int col)
{
int x = 0;
int y = col - 1;
while (x<=row-1 && y>=0)
{
if (arr[x][y] > k)
{
y--;
}
else if (arr[x][y] < k)
{
x++;
}
else
{
return 1;
}
}
}
int main()
{
int arr[3][3] = { {2,3,4},{5,6,7},{8,9,10} };
int k = 6;
int ret = FindNum(arr, k, 3, 3);
if (ret == 1)
{
printf("找到了\n");
}
else
{
printf("找不到\n");
}
return 0;
}
杨氏矩形查找数问题
最新推荐文章于 2025-05-15 12:19:42 发布