#include<stdio.h>
double max=0,min=0;
int main()
{
double average(double a[],int j);
double score[10];
int i;
printf("ÇëÊäÈë10¸öѧÉúµÄ³É¼¨£º");
for(i=0;i<10;i++)
scanf("%lf",&score[i]);
printf("ƽ¾ù³É¼¨£º%lf\n×î´óÖµ£º%lf\n×îСֵ£º%lf\n" ,average(score,10),max,min);
return 0;
}
double average(double a[],int j)
{
double sum=a[0],aver;
int n;
max=min=a[0];
for(n=1;n<10;n++)
{
if(a[n]>max)max=a[n];
if(a[n]<min)min=a[n];
sum=sum+a[n];
}
aver=sum/j;
return aver;
}
温馨提示:答案为网友推荐,仅供参考
第1个回答 2017-12-25
#include<stdio.h>
double max=0,min=0;
int main() {
double average(double a[],int j);
double score[10];
int i;
printf("ÇëÊäÈë10¸öѧÉúµÄ³É¼¨£º");
for(i=0; i<10; i++)
scanf("%lf",&score[i]);
average(score,10);
printf("ƽ¾ù³É¼¨£º%lf\n×î´óÖµ£º%lf\n×îСֵ£º%lf\n" ,average(score,10),max,min);
return 0;
}
double average(double a[],int j) {
double sum=a[0],aver;
int n;
max=min=a[0];
for(n=1; n<10; n++) {
if(a[n]>max)max=a[n];
if(a[n]<min)min=a[n];
sum=sum+a[n];
}
aver=sum/j;
return aver;
}
double max=0,min=0;
int main() {
double average(double a[],int j);
double score[10];
int i;
printf("ÇëÊäÈë10¸öѧÉúµÄ³É¼¨£º");
for(i=0; i<10; i++)
scanf("%lf",&score[i]);
average(score,10);
printf("ƽ¾ù³É¼¨£º%lf\n×î´óÖµ£º%lf\n×îСֵ£º%lf\n" ,average(score,10),max,min);
return 0;
}
double average(double a[],int j) {
double sum=a[0],aver;
int n;
max=min=a[0];
for(n=1; n<10; n++) {
if(a[n]>max)max=a[n];
if(a[n]<min)min=a[n];
sum=sum+a[n];
}
aver=sum/j;
return aver;
}
printf()从右向左调用返回值