利用指针求数组元素的平均值。【样例输入】4 -1 -3 5 6 8 -2 -6【样例输出】平均值:1375根据以上要求补全以下程序片段#includestdiohint main int a8 p; float ave; printf平均值:g ave;
#include<stdio.h> int main() { int a[8], *p; float *ave,sum=0;//sum用来求和 for(p=a;p<a+8;p++){ scanf("%d",p); sum+=*p;//累加每个元素值 } ave=&sum/8;//求平均值 printf("平均值:%g", *ave); }
原文地址: https://www.cveoy.top/t/topic/fnNL 著作权归作者所有。请勿转载和采集!