</pre><pre class="java" name="code">import java.util.Scanner;
public class Twodimensional {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.printf("Enter the number of rows and columns of the array:");
Scanner input = new Scanner(System.in);
int row = input.nextInt();
int column = input.nextInt();
double[][] d = new double[row][column];
System.out.println("Enter the array:");
for (int i = 0; i < row; i++)
for (int j = 0; j < column; j++)
d[i][j] = input.nextDouble();
double max = 0;
int r = 0, c = 0 ;
for (int i = 0; i < row; i++)
for (int j = 0; j < column; j++)
if (d[i][j] > max) {
max = d[i][j];
r = i;
c = j;
}
System.out.println("The location of the largest element is " + max
+ " at (" + r + "," + c + ")");
}
}
截图: