给定一个矩阵int matrixA[m][n],每行每列都是增序的,实现一个算法判断矩阵中的是否包含某个元素element
bool Find(int* matrix, int rows, int columns, int number)
{bool found = false;
if(matrix != NULL && rows > 0 && columns > 0)
{
int row = 0;
int column = columns - 1;
while(row < rows && column >=0)
{
if(matrix[row * columns + column] == number)
{
found = true;
break;
}
else if(matrix[row * columns + column] > number)
-- column;
else
++ row;
}
}
return found;
}