int search(int **matrix,int x,int m,int n)
{
// x element to be searched m,n row n column indices
int row= m-1 , col = 0;
while( row >=0 && col < n)
{
if(matrix[row][col]==x)
return true;
else if(matrix[row][col] > x) row--;
else col++;
}
return false;
}
No comments:
Post a Comment