#include <stdio.h> main() { int t,x; float sum; t=0; sum=0; scanf("%d",&x); if(x==-1) { printf("无数据"); } else{ while (x!=-1) { sum+=x; t++; scanf("%d",&x); } printf("%0.2f", sum/t); } }
标签:正整数,平均值,sum,printf,scanf,小数 From: https://www.cnblogs.com/lachesism/p/16732929.html