The following piece of code takes the input but does not execute or return any output.It takes a matrix and its size and an integer to be searched as input. I am failing to understand the issue here.
#include<iostream>
using namespace std;
int main()
{
int n, m;
cin >> n >> m;
int a[n][m];
int t;
cin >> t;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
cin >> a[i][j];
}
}
int r = 0, c = m - 1;
bool found = false;
while (r < n && c >= 0)
{
if (a[r][c] == t)
{
found = true;
}
else if (a[r][c] < t)
{
r++;
}
else
{
c--;
}
}
if(found)
{
cout << "found";
}
else
{
cout << "not found";
}
return 0;
}