#define?_CRT_SECURE_NO_WARNINGS
#include
#include?
double?fun (int?s[])
{
double?sum?=?0.0; //Assigning an integer value like this>? It must be wrong, change it to double type
< p> int?c?=?0,?i?=?0;//My avatar, surprise
while?(s[i]?!=?0)
{
if?(s[i]>0)
{
sum?+=?s[i];
c++;
}
i++;
}
sum?/=?c; // Slash error
return?sum; //For remainder, sum should be returned
}
int?main()
{< /p>
int?x[1000];?int?i?=?0;
do
{
scanf("%d ",?&x[i]);
}?while?(x[i++]?!=?0);
printf("%lf\n",?fun (x));
system("pause");
return?0;
}
Wrong place in the code The comments are done, and the design idea needs to be changed. The 0 does not necessarily appear at the end.