No Title

Author: 0c93aeca55

22 March 2024

Views: 48

import java.util.*;
import java.util.Scanner;
class saddlePoint {
public static void main(String[] args) {
int i,j,k,c=0,f=0;
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int arr[][]=new int[n][n];
System.out.println("saddle point found:");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
arr[i][j]=sc.nextInt();
}
}
int max,min;
for(i=0;i<n;i++)
{
min=arr[i][0];
for(j=0;j<n;j++)
{
if(arr[i][j]<min)
{
min=arr[i][j];
c=j;
}
}
max=arr[0][c];
for(k=0;k<n;k++)
{
if(arr[k][c]>max)
{
max=arr[k][c];

}
}
if(min==max)
{
System.out.println("saddle point found:"+min);
f=1;
}

}
if(f==0)
{
System.out.println("saddle point not found");

}



}
}


Edit Code:

Please enter an edit code

Edit codes must be at least 20 characters

Share