You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
public class Jb17_ArrDemo
|
|
|
|
|
{
|
|
|
|
|
public static void main(String[] args)
|
|
|
|
|
{
|
|
|
|
|
/*<EFBFBD><EFBFBD><EFBFBD>鶨<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ1<EFBFBD><EFBFBD>
|
|
|
|
|
Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[] <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = new Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[Ԫ<EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>鳤<EFBFBD><EFBFBD>];
|
|
|
|
|
<EFBFBD><EFBFBD>ʽ2<EFBFBD><EFBFBD>
|
|
|
|
|
Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[] <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = new Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[] {Ԫ<EFBFBD><EFBFBD>,Ԫ<EFBFBD><EFBFBD>,........};
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԽDZ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD>DZ꿪ʼ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
//int [] arr = new int[]{2,54,4,5,4,4,5,79};
|
|
|
|
|
int [] arr = {-2,-5,-79,-9};
|
|
|
|
|
for (int x=0;x<arr.length ; x++)
|
|
|
|
|
{
|
|
|
|
|
System.out.println("arr["+x+"] = "+arr[x]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int max = getMax(arr);
|
|
|
|
|
System.out.println("<22><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>"+max);
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD>幦<EFBFBD><E5B9A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
public static int getMax(int[] arr)
|
|
|
|
|
{
|
|
|
|
|
int max = arr[0];
|
|
|
|
|
for (int x=1 ;x<arr.length ;x++ )
|
|
|
|
|
{
|
|
|
|
|
if (arr[x]>max)
|
|
|
|
|
{
|
|
|
|
|
max = arr[x];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return max;
|
|
|
|
|
}
|
|
|
|
|
}
|