Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
38 lines (34 loc) · 1.24 KB

File metadata and controls

38 lines (34 loc) · 1.24 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import java.util.Scanner;
public class Location {
public int row;
public int column;
public double maxValue;
public static Location locateLargest(double[][] a) {
Location forReturn = new Location();
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[i].length; j++) {
if (a[i][j] > forReturn.maxValue) {
forReturn.maxValue = a[i][j];
forReturn.row = i;
forReturn.column = j;
}
}
}
return forReturn;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the number of row and collumn of array: ");
int row = sc.nextInt();
int column = sc.nextInt();
double size[][] = new double[row][column];
System.out.print("Enter the array: ");
for (int i = 0; i < row; i++) {
for (int j = 0; j < column; j++) {
size[i][j] = sc.nextDouble();
}
}
Location display = Location.locateLargest(size);
System.out.println("The location of largest element is " + display.maxValue + " at (" + display.row + "," + display.column + ")");
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.