package Hello;
import java.util.Scanner;
public class call_number {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in =new Scanner(System.in);
int number = in.nextInt();
int sum = 0;
int count = 0 ;
do {
if(number !=-1)
{
number = in.nextInt();
sum=sum+number;
count=count+1;
}
}while(number !=-1);
if(count>0) {
System.out.println("平均数为:"+(double)(sum/count));
}
}
}
JAVA求任意个数字的平均数(输入-1截止)
最新推荐文章于 2023-07-27 14:53:54 发布