题解 | 求平均数
求平均数
https://www.nowcoder.com/practice/41e59cee1221424bb9291435aae79ae9
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int sum=0,count=0,box=scan.nextInt();
while(box>=0)
{
sum+=box;
count++;
box=scan.nextInt();
}
double ave=sum/1.0/count;
System.out.printf("%.2f",ave);
}
}
