Jan

23

#include<stdio.h>
#include<conio.h>
main() {
int a[10][10],i,j,k,n,m,min,max,col=0,flag=0,sad=0;
clrscr();
printf(“enter order m,n of mxn matrix”);
scanf(“%d %d”,&m,&n);
printf(“enter elements row-wise”);
for(i=0;i<m;i++)  {
for(j=0;j<n;j++)     {
scanf(“%d”,&a[i][j]);
}
}
printf(“\n given matrix is \n\n”);
for(i=0;i<m;i++) {
for(j=0;j<n;j++)
{
printf(“%d\t”,a[i][j]);
}
printf(“\n”);
}

for(i=0;i<m;i++) {
min=a[i][0];
for(j=1;j<n;j++)  {
if(a[i][j]==min)      {
flag=1;
}
if(a[i][j]<min)    {
min=a[i][j];
col=j;
flag=0;
}
}
if(flag==1)
printf(“\n no saddle point for row %d”,i+1);
if(flag==0)       {
max=a[0][col];
for(k=1;k<m;k++)  {
if(a[k][col]==max)   {
flag=1;
break;
}   else   {
if(a[k][col]>max)    {
max=a[k][col];
}
}
}
if(max==min && flag !=1)
{
printf(“\n saddle pt.at (%d,%d)”,i+1,col+1);
sad=1;
}
}   // flag=0;

}
if(sad==0)
printf(“\n no saddle poit in matrix “);

getch();

}


Leave a Reply