double average(double *a, int n);
{
double sum,*pt=a;
sum=0.0;
for(int i=0;i
}
mian()
{
int num;
double *a;
printf("输入数组元素的个数:");
scanf("%d",&num);
a=(double *)malloc(num);
input(a);
printf(a);
printf("数组所有数的平均值为:%f.",average(a,num));
free(a);
return 0;
}
#include
# include
double average(double a[], int n)
{
int i;
double sum=0.0;
for(i=0;i
return sum/n;
}
input(double a[],int n)
{
int i;
printf("请输入数据:\n");
for(i=0;i
scanf("%lf",&a[i]);
}
}
print(double a[],int n)
{
int i;
printf("\n所有数据如下:\n");
for(i=0;i
printf("%.2lf ",a[i]);
}
}
main()
{
int n;
double *a;
printf("输入数组元素的个数:");
scanf("%d",&n);
a=(double *)malloc(n);
input(a,n);
print(a,n);
printf("\n数组所有数的平均值为:%.2lf.\n",average(a,n));
free(a);
}
5分好少的说~