7. WRITE A C PROGRAM TO FIND THE SADDLE POINT OF A MATRIX.
DEFN: GIVEN A
RXC MATRIX, A,
I.E. R ROWS
AND C COLUMNS
WE
DEFINE A SADDLE-POINT
AS SADDLE_PT (A)
FOR A ROW I
AND COLUMN J IS THAT A(I,J) THAT IS THE MINIMUM OF
ROW I AND THE MAXIMUM OF COL J.
SOURCE CODE:
#include<stdio.h>
#include<conio.h>
main()
{
int a[10][10],i,j,k,n,min,max,col,m;
//clrscr();
printf("enter order m,n of mxn matrix : ");
scanf("%d %d",&m,&n);
printf("enter elements row-wise\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
}
}
for(i=0;i<m;i++)
{
min=a[i][0];
for(j=0;j<n;j++)
{
if(a[i][j]<=min)
{
min=a[i][j];
col=j;
}
}
max=a[0][col];
for(k=0;k<m;k++)
{
if(a[k][col]>=max)
{
max=a[k][col];
}
}
if(max==min)
printf("saddle pt.at (%d,%d)",i+1,col+1);
}
//getch();
}
1 comments:
nt giving correct output
Post a Comment