Write a C program An element of a matrix is said to be \"Saddle Point\" if it is
ID: 3762662 • Letter: W
Question
Write a C program
An element of a matrix is said to be "Saddle Point" if it is the strictly largest element (max) in its row and the strictly smallest element (min) in its column. For example, the matrix shown below has 2 saddle points: (A matrix may have 0-2 saddle points) Please write a C program that ask the user to input any matrix (size of matrix, and all elements in matrix), and output any saddle point(s) in the matrix (output the value and position of the saddle points). Deliverables: Turn in your C code file for Q4 (.c file, not need for the object .o file nor the executables) and results/answers for Q1-Q3.Explanation / Answer
#include<stdio.h>
#include<conio.h>
main()
{
int x[5][5];
int colsize,m,n,min,max;
printf(“enter the matrix”);
scanf(“%d%d”&m,&n);
for (int i=0;i<n;i++)
{
for (int j=0;j<n;j++)
{
scanf(“%d”,&x[i][j]);
}
}
if(a[i][j]<=min)
{
min=a[i][j];
col=j;
}
for(int l=0;l<m;l++)
{
if(a[l][colsize]>=max)
{
max=a[l][colsize];
}
}
if(max==min)
{
printf("saddle point(%d,%d)",i+1,colsize+1);
}
getch();
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.