尝试运行了以下代码,可是输入负数后没有输出什么来,是代码哪里出问题了吗
问题
代码
#include<stdio.h>
double Average(int scores[],int people)
{
double average;
double sum = 0;
int x;
for(x=0; x<people; x++)
{
sum = sum + scores[x];
}
average = sum/people;
return average;
}
void ReadScore(int scores[],int people,int average)
{
int amount = 0;
int i;
for(i=0; i<people; i++)
{
if(scores[i] > average)
amount++;
}
printf("%d",amount);
}
int main(void)
{
int people = 0;
double average;
int scores[40];
int score;
scanf("%d",&score);
while(score>=0){
scores[people]=score;
people++;
scanf("%d",&score);
}
average=Average(scores[40],people);
ReadScore(scores[40],people,average);
return 0;
}