题目:
解决方法:
1 //package com.algorithm.java.blueBirdge; 2 3 //import java.util.Arrays; 4 import java.util.Scanner; 5 6 public class Main { 7 public static void main(String[] args){ 8 Scanner read =new Scanner(System.in); 9 int max=-20000; 10 int min=20000; 11 int sum=0; 12 int n=read.nextInt(); 13 int F[]=new int [n]; 14 for (int i=0;i<F.length;i++){ 15 F[i] =read.nextInt(); 16 } 17 for(int i=0;i<F.length;i++){ 18 sum=sum+F[i]; 19 if(max<F[i]){ max=F[i]; 20 } 21 if(min>F[i]){ min=F[i]; 22 } 23 } 24 System.out.println(max); 25 System.out.println(min); 26 System.out.println(sum); 27 } 28 }
测试结果:
测试成功!