Java语言程序设计(基础篇)第十版

9.13 

location

package adsads;
//import java.util.Arrays;
import java.util.Date;
//import java.util.Random;

public class adfsa
{ public static void main(String[] args)
{
double[][] a={{23.5,35,2},{4.5,3,45},{35,44,55}};
Location sb=new Location();
sb=sb.locateLargest(a);
System.out.println("The maxValue is"+sb.maxValue+"and teh row is"+sb.row+"the column is"+sb.column);
}
}
class Location{
public int row;
public int column;
public double maxValue;
Location(){

}
public int getRow(){
return row;
}
public void setRow(int row){
this.row=row;
}
public int getColumn(){
return column;
}
public void setColumn(int column){
this.column=column;
}
public double getMaxValue(){
return maxValue;
}
public void setMaxValue(double maxValue){
this.maxValue=maxValue;
}
public static Location locateLargest(double[][] a){
int row=0;
int column=0;
double maxValue=a[0][0];
for(int i=0;i for(int j=0;j {
if(maxValue maxValue=a[i][j];
row=i;
column=j;
}
Location ic=new Location();
ic.row=row;
ic.column=column;
ic.maxValue=maxValue;
return ic;
}
}

你可能感兴趣的:(Java语言程序设计(基础篇)第十版)