#include
float sum(float *array, int number);
float average(float *array, int number);
void main()
{
float a[10];
int i;
printf("请输入数组:\n");
for(i=0;i<10;i++)
{
scanf("%f",&a[i]);
}
printf("和为%f\n",sum(a,10));
printf("平均数为:%f\n",average(a,10));
}
float sum(float *array, int number)
{
int j;
float s=0;
for(j=0;j
return s;
}
float average(float *array, int number)
{
int j;
float s=0, aver=0;
for(j=0;j
aver = s/number;
return aver;
}
float sum(float *array,int number)
{
int i = 0;
float result = 0;
for (i = 0; i < number; i++)
{
result = *(array + i) + result;
}
return result;
}
float average(float *array,int number)
{
int i = 0;
float result;
for (i = 0; i < number; i++)
{
result = result + *(array + i);
}
return result / number;
}