for循环遍历并输出数组,通过卡的思想来卡出最大值和最小值
public class ArrayMaxMin
{
public static void main(String arg[])
{
int i,min,max;
int A[] = {2525,6565,9887,3645,4567};
min = max = A[0];
System.out.print("数组A的元素包括:");
for(i=0;i<A.length;i++)
{
System.out.print(A[i]+" ");
if(A[i]>max)
{
max=A[i];
}
if(A[i]<min)
{
min=A[i];
}
}
System.out.println("\n数组的最大值是:"+max);
System.out.println("\n数组的最小值是:"+min);
}
}