#include
#define N 100
double sum(double [],int); //函数的声明
int main()
{
double a[N];
double s = 0.0,aver = 0.0;
printf("Please input 100 real numers!\n");
for (int i = 0; i < N; i++)
{
scanf("%lf",a+i);
}
s = sum(a,N); //函数调用
aver = s/N; //求平均值
for(int i=0;i
if(a[i]
printf("sum = %lf,average = %lf\n",s,aver);
return 0;
}
//求和函数的实现部分
double sum(double array[],int len)
{
int i;
double sum = 0.0;
for (i = 0; i < len; i++)
{
sum += array[i];
}
return sum;
}
#include
int main()
{
int a[10];
int i,sum=0;
double average;
for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
sum+=a[i];
}
average=sum/10.0;
printf("平均值是%.2lf.\n",average);
for(i=0;i<10;i++)
{
if(a[i]printf("%d\t%d\n",a[i],i);
}
}