源程序:
import java.util.Scanner;
public class p78_1 {
public static void main(String[] args)
{
int N = 7;
int []a=new int[N];
int sum=0;
Scanner reader=new Scanner(System.in);
System.out.print("请输入7个成绩:");
for(int i=0;i<7;i++)
a[i]=reader.nextInt();
for(int i=0;i<7;i++)
{
sum=sum+a[i];
}
int avg=sum/N;
System.out.print("大于平均成绩的值是:");
for(int i=0;i<7;i++)
{
if(a[i]>avg)
System.out.print(a[i]+" ");
}
reader.close();
//System.out.println("7个数之和为:"+sum);
}
}
运行结果: