import java.util.Scanner;
public class h
{
public static void main(String[] args)
{
// TODO Auto-generated method stub
System.out.print("Enter the number of rows and colums of the array :");
Scanner input = new Scanner(System.in);
int row = input.nextInt();
int column = input.nextInt();
System.out.println("Enter the array: ");
double[][] a = new double[row][column];
for (int i = 0; i < row; i++)
{
for (int j = 0; j < column; j++)
{
a[i][j] = input.nextDouble();
}
}
Location location = new Location();
Location.locateLargest(a);
System.out.println("The location of the largest is "+ location.getMax() + " at (" + location.getRow() + " , "+ location.getColumn() + ")");
}
}
class Location
{
private static int row;
private static int column;
private static double max;
public int getRow()
{
return row;
}
public int getColumn()
{
return column;
}
public double getMax()
{
return max;
}
public static Location locateLargest(double[][] a)
{
row = 0;
column = 0;
max = 0;
for (int i = 0; i < a.length; i++)
{
for (int j = 0; j < a[i].length; j++)
{
if (a[i][j] > max)
{
max = a[i][j];
row = i;
column = j;
}
}
}
return null;
}
}
8.13**
最新推荐文章于 2023-10-10 11:09:16 发布