Saddle point- it is that element in a matrix when it is smallest in a row and largest in the same column it exist. There can be multiple saddle points and zero saddle points in a matrix. Here is a java program for you in BlueJ / Java for saddle point.

import java.io.*; class saddle { public static void main(String args[])throws IOException { int i,k,j,c1=0,t=0,c2=0,z=0; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("enter the number of rows in the matrix:"); int n=Integer.parseInt(br.readLine()); System.out.println("enter the number of columns in the matrix:"); int m=Integer.parseInt(br.readLine()); int a[][]=new int[n][m]; System.out.println("enter the elements of the matrix:"); for(i=0;i<n;i++)< span=""> { for(j=0;j<m;j++)< span=""> a[i][j]=Integer.parseInt(br.readLine()); } System.out.println("matrix is:"); for(i=0;i<n;i++)< span=""> { for(j=0;j<m;j++)< span=""> System.out.print(a[i][j]+" "); System.out.println(); } for(i=0;i<n;i++)< span=""> { for(j=0;j<m;j++)< span=""> { z=a[i][j]; c1=0; c2=0; for(k=0;k<m;k++)< span=""> { if(z<=a[i][k]) c1++; } for(k=0;k<n;k++)< span=""> { if(z>=a[k ][j]) c2++; } if(c1==m && c2==n) { t=1; System.out.println("saddle pt="+z); } } } if(t!=1) System.out.println("there is no saddle point"); } }

## OUTPUT:

Tags: saddle point program in blueJ, program for saddle point in java, java program for saddle point

Helpful … pls upload ones having scanner classes