o/p is not coming.
what is the eeror in this code of searching the element
Staircase searching
cb ide is not working right now
have debugged your code here
#include<iostream>
using namespace std;
int main(){
int m,n;
cin>>m>>n;
int a[100][100];
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cin>>a[i][j];
}
}
int key;
cin>>key;
int i=0;
int j=n-1;
while(i<=m-1 && j>=0){
if(key>a[i][j]){
i++;
}
else if(key<a[i][j]){
j--;
}
else{
cout<<i<<endl;
cout<<j<<endl;
break;
}
}
return 0;
}
Run it here
https://www.tutorialspoint.com/compile_cpp_online.php
thanku so much got it
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.