c语言程序,大神帮看下程序哪里错了,谢谢!

c语言程序,大神帮看下程序哪里错了,谢谢!#include <conio.h>
#include <stdio.h>
#include <string.h>
int main()
{
double fun(double score[],double m, double below[])
double i, n, below[9];
double score[9]=10,20,30,40,50,60,70,80,90;
clrscr();
n=fun(score,9,below);
printf("\nBelow the average score are: ");
for(i=0;i<n;i++)
printf("%d",below[i]);
}
double fun(double score[],double m, double below[])
{
double i,j=0;
float average=0.0;
for(i=0;i<m;i++)
average=average+score[i];
average/=m;
for(i=0;i<m;i++)
if(score[i]<average)
below[j]=score[i];
j++;
return j;
}

#include <conio.h>

#include <stdio.h>

int main()

{

int fun(double score[],int m, double below[]);

     double below[9];

     int i, n;

     double score[9]={10,20,30,40,50,60,70,80,90};

    // clrscr();

     n=fun(score,9,below);

     printf("\nBelow the average score are:\n");

     for(i=0;i<n;i++)

       printf("%.1lf ",below[i]);

}

 int fun(double score[],int m, double below[])

 {

     int i,j=0;

     double average=0.0;

     for(i=0;i<m;i++)

       average=average+score[i]; 

average/=m;

     for(i=0;i<m;i++)

       if(score[i]<average) 

         below[j++]=score[i];

     return j; 

 }

追问

编写函数float fun(int m,float score[],float below[]),它的功能是:将低于平均分的人数作为函数值返回,并将低于平均分的成绩放在below数组中(m表示score的长度,score表示成绩)。例如,当score数组中的数据为:10、20、30、40、50、60、70、80、90时,函数返回4,below中的数据应为:10、20、30、40。编写fun函数和主函数;主函数内输入成绩,调用fun函数,输出所有成绩、低于平均分的人数、低于平均分的成绩

非常感谢😘

谢谢你

温馨提示:内容为网友见解,仅供参考
第1个回答  2016-12-23
你这是要排序么?
嗯明显一个错误你的below[]只传了数值到double fun(xxx)这个函数,算是一个临时变量,在主函数中below[]的值是不会随你fun函数的操作而改变的。。想改的话要传指针哈追问

那怎么改😥,谢谢

追答

改成double *below[]呗 0.0
把所有的below改成指针类型。。嗯就是前面加*

相似回答