package com.imoocEx;
import java.util.Scanner;
public class scNum {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input=new Scanner(System.in);
System.out.println("请输入你想要的数组数量");
int nu=input.nextInt();
int[] num=new int[nu];
int minNum=num[0];
int maxNum=num[0];
double sum=0;
double avg=0;
for(int i=0;i<nu;i++){
System.out.println("请输入你想要的数");
num[i]=input.nextInt();
sum+=num[i];
}
System.out.println("和为:"+sum);
for(int i=0;i<nu;i++){
if(num[i]>maxNum){
maxNum=num[i];
}
}
System.out.println("最大的数"+maxNum);
for(int i=0;i<nu;i++){
if(num[i]<minNum){
minNum=num[i];
}
}
System.out.println("最小的数"+minNum);
avg=sum/nu;
System.out.println("平均数为:"+avg);
}
}
Caballarii
相关分类