c语言相关---为什么for 循环循环10次,却仅执行9次。例如输入10个数,却循环9次;
#include <stdio.h>void main()
{
float average(float array, int n);
float aver,ave;
int i,n;
for (i=0;i<=9;++i)
{
scanf("%f ",&aver);
printf("%d---%f\n",i,aver);
}
scanf("%d",&n);
ave=average(aver , n);
printf("%f\n",ave);
}
float average(float array, int n)
{
int i;
float sum=0,aver;
for (i=0;i<n;i++)
sum=sum+array;
aver = sum / n;
return aver;
}
路过看一看= =!:lol:
页:
[1]