Sir in this problem (matrix search)

#include
#include
using namespace std;
int search(int a[][100],int n,int m,int x)
{
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(a[i][j]==x)
{
cout<<“1”<<endl;
return 0;
}
}
}
cout<<“0”;
return 0;
}
int main()
{
int a[100][100];
int n;
int m;
cin>>n>>m;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cin>>a[i][j];
}
}
sort(a,a+n);
int x;
cin>>x;
search(a,n,m,x);
return 0;
}

when i am using sort function in this code it is not working.if i remove sort function then it is working properly why so???

@Abhishmu5 how do you expect the sort function to work on a 2d array?

i understood sir whatever you are trying to say.
Thank u

1 Like

@Abhishmu5 please mark your doubt as resolved

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.