-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavalab7.java
More file actions
56 lines (53 loc) · 1.65 KB
/
Copy pathjavalab7.java
File metadata and controls
56 lines (53 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
class javalab7 {
public static void main(String[] st) {
java.util.Scanner sc = new java.util.Scanner(System.in);
int column, max = 0, min = 0, row, i = 0, j = 0, f = 0,indexj=0; // ,changei,changej,numi,numj
System.out.print("enter no. of rows:");
row = sc.nextInt();
System.out.print("enter no. of columns:");
column = sc.nextInt();
int[][] arr = new int[row][column];
for (i = 0; i < row ; i++) {
for (j = 0; j < column; j++) {
arr[i][j] = sc.nextInt();
}
}
sc.close();
// Find the saddle point
for (i = 0; i < row; i++)
{
for (j = 0; j < column; j++)
{
max = arr[i][j];
min = arr[i][j];
indexj=j;
// for maximum element in column
for (int k = 0; k < row; k++)
{
if (arr[k][j] > max)
{
max = arr[k][j];
}
}
// for mximum element in row
for (int k = 0; k < column; k++)
{
if (arr[i][k] < min)
{
min = arr[i][k];
indexj=k;
}
}
if (min == max)
{
System.out.println("Saddle point is " + max + " at i=" + i + " j=" + indexj);
f = 1;
}
}
}
if (f != 1)
{
System.out.println("NO saddle point");
}
}
}