1-100所有奇数的平均值
# include <stdio.h>int main (void)
{
int i;
int sum = 0; //所有奇数的和
int num = 0; //所有奇数的数量
int avg; //avg表示平均值
for(i = 0; i <= 100; ++i)
{
if(i%2 == 1)
{
sum = + i;
num = + 1;
}
}
avg = sum / num;
printf("avg = %d\n",avg); //一直提示这一行出错了
return 0;
}