Find people below the average of

There are n individual performance score stored in the array, the test write functions, the function of which is lower than the corresponding average person as a function of the array index value is returned.

int avg(int score[],int n,int below[])
{
    int n,sum,k,avg=0;
    printf("开始处理函数avg()\n");
    for(int i=1;i<=n;i++)
    {
     sum=sum+score[i];
 }
 avg=sum/n;
 for(int m=1;m<=n;m++)
 {
  if(score[m]<avg)
  {
   below[k]=score[m];
   k++;
  }
  cout<<k<<endl;
 }
}
Published 102 original articles · won praise 93 · views 4980

Guess you like

Origin blog.csdn.net/huangziguang/article/details/104596926
Recommended