class Test7
{
public static void main(String[] args)
{
int []arr={11,22,13,54,33,1,3};
System.out.println(getSMM(arr));
}
public static String getSMM(int [] arr)//获取最大最小和值的和
{
int max=arr[0];
int min=arr[0];
int sum=0;
StringBuilder sb=new StringBuilder();
for(int i=0;i<arr.length;i++)
{
if(max<arr[i])
{
max=arr[i];
}
if(min>arr[i])
{
min=arr[i];
}
sum+=arr[i];
}
sb.append("最大值是:"+max+",最小值是:"+min+",和是:"+sum);
return sb.toString();
}
}
|
|