1289: 簡單數據統計

題目

Description

輸入若干個整數求出他們的最小值,最大值,平均值(保留三位有效數字)輸入保證這些數都不超過1000的正整數

Input

輸入若干個整數

Output

求出他們的最小值,最大值,平均值(保留三位有效數字)

Sample Input

2 8 3 5 1 7 3 6
Sample Output

1 8 4.375


代碼塊

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner cn = new Scanner(System.in);
        int min = 1000;
        int max = 0;
        int sum = 0;
        int count =0;
        while(cn.hasNext()){
            int a = cn.nextInt();
            if(min>a) min = a;
            if(max<a) max = a;
            sum += a;
            count++;
        }
        System.out.print(min+" "+max+" ");
        System.out.printf("%.3f\n",1.0*sum/count);
    }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章