Test case 0 is not passes

#include
using namespace std;
void sm(int a[100][100],int r, int c,int k){
int i=0,j=c-1;
while(i<r && j>=0){
if(a[i][j]<k){
i++;
}
else if(a[i][j]>k){j–;

	}
	else if(a[i][j]==k){
		cout<<1;break;
	}
	else{
		cout<<0;break;
	}
}

}
int main() {
int r,c,k;cin>>r>>c;int a[100][100];
for(int i=0;i<r;i++){
for(int j=0;j<c;j++){
cin>>a[i][j];
}
}
cin>>k;
sm(a,r,c,k);
return 0;
}

hi @yashtripathi6969_0cd127807d833066 updated and commented

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.