Loading... 输入任意多个数字,以-1结束输入;计算它们的平均值并输出。 <!--more--> ```java import java.util.Scanner; public class Avrage { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); int number = 0,count = 0, temp; temp = in.nextInt(); while(temp != -1) { number = number + temp; count = count + 1; temp = in.nextInt(); } System.out.println("平均数为="+ 1.0*number/count); } } ```<hr class="content-copyright" style="margin-top:50px" /><blockquote class="content-copyright" style="font-style:normal"><p class="content-copyright">版权属于:Feihong</p><p class="content-copyright">本文链接:<a class="content-copyright" href="https://www.feihong.me/archives/22.html">https://www.feihong.me/archives/22.html</a></p><p class="content-copyright">转载时须注明出处及本声明</p></blockquote> 最后修改:2019 年 12 月 31 日 11 : 05 PM © 允许规范转载 赞赏 如果觉得我的文章对你有用,请随意赞赏 ×Close 赞赏作者 扫一扫支付 支付宝支付 微信支付