#include #include using namespace std; int main() { int a[10],sum=0; double ave; for(int i=0;i<10;i++) { cin>>a[i]; sum+=a[i];//累加十个数 } ave=sum/10.0;//计算平均数,要注意类型转换 printf("%.1f",ave);//输出,保留一位小数 return 0; }

c++给你十个整数计算并输出这十个数的平均数。输入 一行包含十个整数均在1到100范围内两两之间以一个空格分隔。输出 一个数表示这十个整数的平均数。输入样例 1 2 3 4 5 6 7 8 9 10输出样例 55用时内存 1000MS100MB

原文地址: https://www.cveoy.top/t/topic/fzbA 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录