import java.util.Scanner;
public class p78_2 {
final static int N=7;
public static void main(String[] args)
{
int MAX,MIN;
int []a=new int[N];
Scanner reader=new Scanner(System.in);
System.out.print("请输入7个整数:");
for(int i=0;i<N;i++)
{
try
{
a[i]=reader.nextInt();
}catch(Exception e)
{
System.out.println("数组越界!");
}
}
MAX=a[0];
MIN=a[0];
for(int i=1;i<N;i++)
{
if(a[i]>MAX)
MAX=a[i];
if(a[i]<MIN)
MIN=a[i];
}
reader.close();
System.out.print("最大值是:"+MAX + " 最小值是:"+MIN);
}
}
运行结果: