Cannot determine the logic for loop to end

#include
using namespace std;
int main() {
int m, n;
cin>>n>>m;
int a[100][100];
for(int i=0; i<n; i++)
{
for(int j=0; i<m; i++)
{
cin>>a[i][j];
}
}
int t;
cin>>t;
int i =0, j=m-1;
while()
{
if(t>a[i][j])
{
i++;
}
if(t<a[i][j])
{
j–;
}
if(t==a[i][j]){
cout<<1;
break;
}
}

return 0;

}

Refer this https://ide.codingblocks.com/s/229779

Apply the logic same as that in staircase search video in your course. You just have to pick the top right element in the array and start traversing from there accordingly.

Yes I am doing that in this code but I don’t understand the while loop condition

Till when I have to traverse the elments in the matrix.

You have to traverse form top right boundary of matrix till bottom left.
Considering i is for row and j is for column,
You have to travel until i<(matrix size) and j>=0
Your i and j must be within the boundary of the matrix.