```
bool search(int **a, int colnum, int rownum, int k)
{
if(colnum == 0 || rownum == 0) return false;
int sx = colnum - 1, sy = 0;
while ( sx >= 0 && sx<colnum && sy >= 0 && sy<rownum)
{
if (a[sy][sx]>k)
--sx;
else if ( a[sy][sx]<k)
++sy;
else
return true;
}
return false;
}
bool searchMatrix(int** matrix, int matrixRowSize, int matrixColSize, int target) {
return search(matrix,matrixColSize, matrixRowSize,target);
}
```

THX leetcode -_-