Whats wrong with this code?
#include
using namespace std;
void stairCase(int a[][100], int n, int m, int key){
int i = 0; int j =n-1;
while(i<n && j>=0){
if(a[i][j] < key){
i++;
}
else if(a[i][j] > key){
j--;
}
else if(a[i][j] == key){
cout<<1;
break;
}
}
if(i == n || j<0)
cout<<0;
}
int main(){
int n,m,a[100][100], key;
cin>>n>>m;
for(int i = 0; i<n; i++){
for(int j = 0; j<m; j++){
cin>>a[i][j];
}
}
cin>>key;
stairCase(a,n,m,key);
return 0;
}