问题详情

class ABC { int a,b; public ABC(int a, int b) {this.a=a; this.b=b;} public int compareTo(ABC x) {return a*b-x.a*x.b;} } public class XXK5 { public static void main(String[] args) { int [][]d={{3,8},{4,6},{5,6},{2,9},{6,7},{5,8}}; ABC []ar=new ABC[d.length]; int i,k=0; for(i=0; i<ar.length; i++) ar[i]=new ABC(d[i][0],d[i][1]); for(i=1; i<ar.length; i++) if(ar[i].compareTo(ar[k])>0) k=i; System.out.println("k="+k); } }


<span>k、10</span>

<span>k、4</span>

时间:2021-07-17 19:36 关键词:

答案解析

<span>k=4</span>