比较多个int变量大小,但怎么输出最大变量的变量名
System.out.println("Apple="+a+" "+"Pear="+p+" "+"Cherry="
+c+" "+"Watermelon="+w+" "+"Grape="+g);
}
int[] in ={a,p,c,w,g};
int max,temp=0;
max = temp;
for(int i=0;i<5;i++)
{
temp = in[i];
if(temp > max)
max = temp;
}
System.out.println(max);
怎样输出a,p…这些变量对应的名字?

慕虎7386555
浏览 1521回答 1
1回答
-
慕虎7386555
比较也写错了……输出最大的变量,然后还要输出对应的变量名
打开App,查看更多内容